Total Complexity | 4 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | trait StopOnFailure |
||
9 | { |
||
10 | private int $stopOnFailure; |
||
11 | |||
12 | public function withStopSign(int $stopSign): static |
||
13 | { |
||
14 | $instance = clone $this; |
||
15 | $instance->setStopSign($stopSign); |
||
16 | return $instance; |
||
17 | } |
||
18 | |||
19 | protected function setStopSign(int $stopSign): void |
||
20 | { |
||
21 | if (! in_array($stopSign, StopSign::allowed())) { |
||
22 | throw new InvalidArgumentException(sprintf('Invalid stop sign (%s)', $stopSign)); |
||
23 | } |
||
24 | |||
25 | $this->stopOnFailure = $stopSign; |
||
26 | } |
||
27 | |||
28 | public function stopOnFailure(): int |
||
31 | } |
||
32 | } |
||
33 |