Conditions | 6 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public static function filter($value, bool $allowNull = false) |
||
24 | { |
||
25 | if (self::valueIsNullAndValid($allowNull, $value)) { |
||
26 | return null; |
||
27 | } |
||
28 | |||
29 | if ($value instanceof \DateTimeZone) { |
||
30 | return $value; |
||
31 | } |
||
32 | |||
33 | if (!is_string($value) || trim($value) == '') { |
||
34 | throw new FilterException('$value not a non-empty string'); |
||
35 | } |
||
36 | |||
37 | try { |
||
38 | return new \DateTimeZone($value); |
||
39 | } catch (\Exception $e) { |
||
40 | throw new FilterException($e->getMessage(), $e->getCode(), $e); |
||
41 | } |
||
52 |