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