summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/WaitWorkflow.php
blob: 826952c12e6144b3f5b666c8de85df8c500b7749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php


namespace Temporal\Tests\Workflow;


use Temporal\Workflow;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;

#[WorkflowInterface]
class WaitWorkflow
{
    private bool $ready = false;
    private string $value;

    #[SignalMethod]
    public function unlock(
        string $value
    ) {
        $this->ready = true;
        $this->value = $value;
    }

    #[WorkflowMethod(name: 'WaitWorkflow')]
    public function run()
    {
        yield Workflow::await(fn() => $this->ready);

        return $this->value;
    }
}