Conditions | 5 |
Paths | 6 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
61 | 12 | public function setCurrentStatus(Enum $status): void |
|
62 | { |
||
63 | 12 | $isTransitionAllowed = false; |
|
64 | |||
65 | 12 | foreach ($this->allowedTransitions as $transition) { |
|
66 | 12 | if ($transition->getFrom()->getValue() === $this->currentStatus->getValue() |
|
67 | 12 | && $transition->getTo()->getValue() === $status->getValue() |
|
68 | ) { |
||
69 | 3 | $this->currentStatus = $status; |
|
70 | 3 | $isTransitionAllowed = true; |
|
71 | 12 | break; |
|
72 | } |
||
73 | } |
||
74 | |||
75 | 12 | if (!$isTransitionAllowed) { |
|
76 | 9 | throw new InvalidTransitionException('Transition not allowed'); |
|
77 | } |
||
78 | 3 | } |
|
79 | } |
||
80 |