src/Filter/DateTimeZone.php
public static function filter($value, bool $allowNull = false)
    {
        if (self::valueIsNullAndValid($allowNull, $value)) {
            return null;
        }

        if ($value instanceof \DateTimeZone) {
            return $value;
        }

        if (!is_string($value) || trim($value) == '') {
            throw new FilterException('$value not a non-empty string');
        }

        try {
            return new \DateTimeZone($value);
        } catch (\Exception $e) {
            throw new FilterException($e->getMessage(), $e->getCode(), $e);
        }
    }
public static function filter($value, bool $allowNull = false)
    {
        if (self::valueIsNullAndValid($allowNull, $value)) {
            return null;
        }

        if ($value instanceof \DateTimeZone) {
            return $value;
        }

        if (!is_string($value) || trim($value) == '') {
            throw new FilterException('$value not a non-empty string');
        }

        try {
            return new \DateTimeZone($value);
        } catch (\Exception $e) {
            throw new FilterException($e->getMessage(), $e->getCode(), $e);
        }
    }
public static function filter ( $ value , bool $ allowNull = false ) { if ( self :: valueIsNullAndValid ( $ allowNull , $ value ) ) { return null ; } if ( $ value instanceof \ DateTimeZone ) { return $ value ; } if ( ! is_string ( $ value ) || trim ( $ value ) == '' ) { throw new FilterException ( '$value not a non-empty string' ) ; } try { return new \ DateTimeZone ( $ value ) ; } catch ( \ Exception $ e ) { throw new FilterException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Filters the given value into a \DateTimeZone object.

@param mixed   $value     The value to be filtered.
@param boolean $allowNull True to allow nulls through, and false (default) if nulls should not be allowed.

@return \DateTimeZone|null

@throws FilterException if the value did not pass validation.
Filters the given value into a \ DateTimeZone object .