| Conditions | 5 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public static function filter($value, bool $allowNull = false) |
||
| 26 | { |
||
| 27 | if ($allowNull === true && $value === null) { |
||
| 28 | return null; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($value instanceof \Closure) { |
||
| 32 | return $value; |
||
|
|
|||
| 33 | } |
||
| 34 | |||
| 35 | if (is_callable($value)) { |
||
| 36 | return \Closure::fromCallable($value); |
||
| 37 | } |
||
| 38 | |||
| 39 | throw new FilterException('Value "' . var_export($value, true) . '" is not Closure or $allowNull is not set'); |
||
| 40 | } |
||
| 42 |