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