Test Failed
Push — main ( 5f778a...f68dd4 )
by Bingo
06:33
created

ActivityBehaviorUtil   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getActivityBehavior() 0 14 2
1
<?php
2
3
namespace Jabe\Engine\Impl\Util;
4
5
use Jabe\Engine\Impl\Pvm\{
6
    PvmActivityInterface,
7
    PvmException
8
};
9
use Jabe\Engine\Impl\Pvm\Delegate\ActivityBehaviorInterface;
10
use Jabe\Engine\Impl\Pvm\Runtime\PvmExecutionImpl;
11
use Jabe\Engine\Impl\Util\EnsureUtil;
12
13
class ActivityBehaviorUtil
14
{
15
    public static function getActivityBehavior(/*PvmExecutionImpl*/$execution): ?ActivityBehaviorInterface
16
    {
17
        if ($execution instanceof PvmExecutionImpl) {
18
            $id = $execution->getId();
19
20
            $activity = $execution->getActivity();
21
            EnsureUtil::ensureNotNull("Execution '" . $id . "' has no current activity.", "activity", $activity);
22
23
            $behavior = $activity->getActivityBehavior();
24
            EnsureUtil::ensureNotNull("There is no behavior specified in " . $activity . " for execution '" . $id . "'.", "behavior", $behavior);
25
26
            return $behavior;
27
        }
28
        return null;
29
    }
30
}
31