1 | <?php declare(strict_types=1); |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
3 | namespace Star\Component\State\Callbacks; |
||
4 | |||
5 | use Star\Component\State\InvalidStateTransitionException; |
||
6 | use Star\Component\State\StateMachine; |
||
7 | |||
8 | final class CallContextMethodOnFailure implements TransitionCallback |
||
0 ignored issues
–
show
|
|||
9 | { |
||
0 ignored issues
–
show
|
|||
10 | /** |
||
0 ignored issues
–
show
|
|||
11 | * @var string |
||
12 | */ |
||
13 | private $to; |
||
0 ignored issues
–
show
|
|||
14 | |||
15 | /** |
||
0 ignored issues
–
show
|
|||
16 | * @var string |
||
17 | */ |
||
18 | private $method; |
||
0 ignored issues
–
show
|
|||
19 | |||
20 | /** |
||
0 ignored issues
–
show
|
|||
21 | * @var mixed[] |
||
22 | */ |
||
23 | private $args; |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | /** |
||
0 ignored issues
–
show
|
|||
26 | * @param string $to |
||
0 ignored issues
–
show
|
|||
27 | * @param string $method |
||
0 ignored issues
–
show
|
|||
28 | * @param mixed[] $args |
||
0 ignored issues
–
show
|
|||
29 | */ |
||
30 | 1 | public function __construct( |
|
0 ignored issues
–
show
|
|||
31 | string $to, |
||
32 | string $method, |
||
33 | array $args |
||
34 | ) { |
||
0 ignored issues
–
show
|
|||
35 | 1 | $this->to = $to; |
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
36 | 1 | $this->method = $method; |
|
37 | 1 | $this->args = $args; |
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
38 | 1 | } |
|
0 ignored issues
–
show
|
|||
39 | |||
40 | /** |
||
0 ignored issues
–
show
|
|||
41 | * @param mixed $context |
||
0 ignored issues
–
show
|
|||
42 | * @param StateMachine $machine |
||
0 ignored issues
–
show
|
|||
43 | */ |
||
0 ignored issues
–
show
|
|||
44 | 1 | public function beforeStateChange($context, StateMachine $machine): void |
|
45 | { |
||
0 ignored issues
–
show
|
|||
46 | 1 | } |
|
0 ignored issues
–
show
|
|||
47 | |||
48 | /** |
||
0 ignored issues
–
show
|
|||
49 | * @param mixed $context |
||
0 ignored issues
–
show
|
|||
50 | * @param StateMachine $machine |
||
0 ignored issues
–
show
|
|||
51 | */ |
||
0 ignored issues
–
show
|
|||
52 | 1 | public function afterStateChange($context, StateMachine $machine): void |
|
53 | { |
||
0 ignored issues
–
show
|
|||
54 | 1 | } |
|
0 ignored issues
–
show
|
|||
55 | |||
56 | /** |
||
0 ignored issues
–
show
|
|||
57 | * @param InvalidStateTransitionException $exception |
||
0 ignored issues
–
show
|
|||
58 | * @param mixed|object $context |
||
0 ignored issues
–
show
|
|||
59 | * @param StateMachine $machine |
||
0 ignored issues
–
show
|
|||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | 1 | public function onFailure(InvalidStateTransitionException $exception, $context, StateMachine $machine): string |
|
0 ignored issues
–
show
|
|||
64 | { |
||
0 ignored issues
–
show
|
|||
65 | $closure = function (array $args) use ($context) { |
||
66 | 1 | $context->{$this->method}(...$args); |
|
67 | 1 | }; |
|
68 | 1 | $closure($this->args); |
|
69 | |||
70 | 1 | return $this->to; |
|
71 | } |
||
0 ignored issues
–
show
|
|||
72 | } |
||
0 ignored issues
–
show
|
|||
73 |