We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 95.65% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class When extends AbstractRule |
||
| 20 | { |
||
| 21 | public $when; |
||
| 22 | public $then; |
||
| 23 | public $else; |
||
| 24 | |||
| 25 | 8 | public function __construct(Validatable $when, Validatable $then, Validatable $else = null) |
|
| 26 | { |
||
| 27 | 8 | $this->when = $when; |
|
| 28 | 8 | $this->then = $then; |
|
| 29 | 8 | if (null === $else) { |
|
| 30 | 1 | $else = new AlwaysInvalid(); |
|
| 31 | 1 | $else->setTemplate(AlwaysInvalidException::SIMPLE); |
|
| 32 | } |
||
| 33 | |||
| 34 | 8 | $this->else = $else; |
|
| 35 | 8 | } |
|
| 36 | |||
| 37 | 10 | public function validate($input): bool |
|
| 44 | } |
||
| 45 | |||
| 46 | 3 | public function assert($input): void |
|
| 47 | { |
||
| 48 | 3 | if ($this->when->validate($input)) { |
|
| 49 | 2 | $this->then->assert($input); |
|
| 50 | |||
| 51 | 1 | return; |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | $this->else->assert($input); |
|
| 55 | } |
||
| 56 | |||
| 57 | 3 | public function check($input): void |
|
| 66 | } |
||
| 67 | } |
||
| 68 |