summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/AggregatedWorkflow.php
blob: 3299179e9758a9fba0570642e063858c209a1075 (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
<?php

namespace Temporal\Tests\Workflow;

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

#[WorkflowInterface]
class AggregatedWorkflow
{
    private array $values = [];

    #[SignalMethod]
    public function addValue(
        string $value
    ) {
        $this->values[] = $value;
    }

    #[WorkflowMethod(name: 'AggregatedWorkflow')]
    public function run(
        int $count
    ) {
        yield Workflow::await(fn() => count($this->values) === $count);

        return $this->values;
    }
}