| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 3 | private function normalizeRule($rule): Rule |
|
| 39 | { |
||
| 40 | 3 | if (is_callable($rule)) { |
|
| 41 | 2 | $rule = new Callback($rule); |
|
|
|
|||
| 42 | } |
||
| 43 | |||
| 44 | 3 | if (!$rule instanceof Rule) { |
|
| 45 | 1 | throw new \InvalidArgumentException( |
|
| 46 | 1 | 'Rule should be either instance of Rule class or a callable' |
|
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | 2 | if ($this->formatter !== null) { |
|
| 51 | 1 | $rule = $rule->formatter($this->formatter); |
|
| 52 | } |
||
| 53 | |||
| 54 | 2 | return $rule; |
|
| 55 | } |
||
| 57 |