• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wol-soft / php-workflow / 12009837953

25 Nov 2024 12:16PM UTC coverage: 98.408%. Remained the same
12009837953

push

github

wol-soft
PHP8.4 compatibility

371 of 377 relevant lines covered (98.41%)

38.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/src/Step/NestedWorkflow.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPWorkflow\Step;
6

7
use PHPWorkflow\Exception\WorkflowException;
8
use PHPWorkflow\ExecutableWorkflow;
9
use PHPWorkflow\State\ExecutionLog\StepInfo;
10
use PHPWorkflow\State\NestedContainer;
11
use PHPWorkflow\State\WorkflowContainer;
12
use PHPWorkflow\State\WorkflowResult;
13
use PHPWorkflow\WorkflowControl;
14

15
class NestedWorkflow implements WorkflowStep
16
{
17
    private ExecutableWorkflow $nestedWorkflow;
18
    private ?WorkflowContainer $container;
19
    private WorkflowResult $workflowResult;
20

21
    public function __construct(ExecutableWorkflow $nestedWorkflow, ?WorkflowContainer $container = null)
22
    {
23
        $this->nestedWorkflow = $nestedWorkflow;
4✔
24
        $this->container = $container;
4✔
25
    }
26

27
    public function getDescription(): string
28
    {
29
        return "Execute nested workflow";
4✔
30
    }
31

32
    public function run(WorkflowControl $control, WorkflowContainer $container): void
33
    {
34
        try {
35
            $this->workflowResult = $this->nestedWorkflow->executeWorkflow(
4✔
36
                new NestedContainer($container, $this->container),
4✔
37
                // TODO: array unpacking via named arguments when dropping PHP7 support
38
                $container->get('__internalExecutionConfiguration')['throwOnFailure'],
4✔
39
            );
4✔
40
        } catch (WorkflowException $exception) {
×
41
            $this->workflowResult = $exception->getWorkflowResult();
×
42
        }
43

44
        $control->attachStepInfo(StepInfo::NESTED_WORKFLOW, ['result' => $this->workflowResult]);
4✔
45

46
        if ($this->workflowResult->getWarnings()) {
4✔
47
            $warnings = count($this->workflowResult->getWarnings(), COUNT_RECURSIVE) -
1✔
48
                count($this->workflowResult->getWarnings());
1✔
49

50
            $control->warning(
1✔
51
                sprintf(
1✔
52
                    "Nested workflow '%s' emitted %s warning%s",
1✔
53
                    $this->workflowResult->getWorkflowName(),
1✔
54
                    $warnings,
1✔
55
                    $warnings > 1 ? 's' : '',
1✔
56
                ),
1✔
57
            );
1✔
58
        }
59

60
        if (!$this->workflowResult->success()) {
4✔
61
            $control->failStep("Nested workflow '{$this->workflowResult->getWorkflowName()}' failed");
1✔
62
        }
63
    }
64

65
    public function getNestedWorkflowResult(): WorkflowResult
66
    {
67
        return $this->workflowResult;
1✔
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc