Conditions | 3 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
1 | <?php |
||
24 | 16 | public static function new(string $transition) : Transition |
|
25 | { |
||
26 | 16 | $isMatch = preg_match(self::getPattern(), $transition, $matches); |
|
27 | 16 | $withExpectedNamedCaptures = isset($matches['current_state'], $matches['input'], $matches['next_state']); |
|
28 | |||
29 | 16 | if (!$isMatch || !$withExpectedNamedCaptures) { |
|
30 | 1 | throw new TransitionPatternMismatch($transition, self::$pattern); |
|
31 | } |
||
32 | |||
33 | 15 | return new self( |
|
34 | 15 | FlyweightState::named($matches['current_state']), |
|
35 | 15 | FlyweightInput::named($matches['input']), |
|
36 | 15 | FlyweightState::named($matches['next_state']) |
|
37 | ); |
||
38 | } |
||
39 | |||
62 |