1 | <?php declare(strict_types=1); |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | /** |
||
0 ignored issues
–
show
|
|||
3 | * This file is part of the php-state project. |
||
4 | * |
||
5 | * (c) Yannick Voyer <[email protected]> (http://github.com/yvoyer) |
||
6 | */ |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | namespace Star\Component\State; |
||
9 | |||
10 | final class InvalidStateTransitionException extends \Exception |
||
0 ignored issues
–
show
|
|||
11 | { |
||
0 ignored issues
–
show
|
|||
12 | /** |
||
0 ignored issues
–
show
|
|||
13 | * @param string $transition |
||
0 ignored issues
–
show
|
|||
14 | * @param string|object $context |
||
0 ignored issues
–
show
|
|||
15 | * @param string $currentState |
||
0 ignored issues
–
show
|
|||
16 | * |
||
17 | * @return static |
||
18 | */ |
||
19 | 11 | public static function notAllowedTransition( |
|
0 ignored issues
–
show
|
|||
20 | string $transition, |
||
21 | $context, |
||
22 | string $currentState |
||
23 | ): self { |
||
0 ignored issues
–
show
|
|||
24 | 11 | if (\is_object($context)) { |
|
25 | 2 | $context = \get_class($context); |
|
26 | } |
||
27 | |||
28 | 11 | return new static( |
|
29 | 11 | \sprintf( |
|
30 | 11 | "The transition '%s' is not allowed when context '%s' is in state '%s'.", |
|
31 | 11 | $transition, |
|
32 | 11 | $context, |
|
33 | 11 | $currentState |
|
34 | ) |
||
35 | ); |
||
36 | } |
||
0 ignored issues
–
show
|
|||
37 | } |
||
0 ignored issues
–
show
|
|||
38 |