Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function __call(string $name, array $arguments) |
||
13 | { |
||
14 | if (false === str_starts_with($name, 'is')) { |
||
15 | throw new Exception('Conditional methods must start with "is"!'); |
||
16 | } |
||
17 | |||
18 | $property = lcfirst(substr($name, 2)); |
||
19 | |||
20 | $property = $this->conditionals()[$property] ?? $property; |
||
21 | |||
22 | if (false === property_exists($this, $property)) { |
||
23 | throw new Exception('Method not found!'); |
||
24 | } |
||
25 | |||
26 | $likelihood = $arguments[0] ?? Likelihood::VERY_LIKELY; |
||
27 | |||
28 | return $this->{$property} === Likelihood::fromKey($likelihood); |
||
29 | } |
||
33 |