| Conditions | 8 | 
| Paths | 5 | 
| Total Lines | 20 | 
| Code Lines | 10 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 20 | public static function filter($value, $allowNull = false) | ||
| 21 |     { | ||
| 22 |         if ($allowNull !== false && $allowNull !== true) { | ||
| 23 |             throw new \InvalidArgumentException('$allowNull was not a boolean value'); | ||
| 24 | } | ||
| 25 | |||
| 26 |         if ($value === null && $allowNull) { | ||
| 27 | return null; | ||
| 28 | } | ||
| 29 | |||
| 30 |         if ($value instanceof \DateTimeZone) { | ||
| 31 | return $value; | ||
| 32 | } | ||
| 33 | |||
| 34 |         if (!is_string($value) || trim($value) == '') { | ||
| 35 |             throw new \Exception('$value not a non-empty string'); | ||
| 36 | } | ||
| 37 | |||
| 38 | return new \DateTimeZone($value); | ||
| 39 | } | ||
| 40 | } | ||
| 41 |