protected function castToType($value, $type)
    {
        switch ($type) {
            case self::TYPE_CAST_INT:
                $newValue = filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_BOOL:
                $newValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_FLOAT:
                $newValue = filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
        }

        return $value;
    }
protected function castToType($value, $type)
    {
        switch ($type) {
            case self::TYPE_CAST_INT:
                $newValue = filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_BOOL:
                $newValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_FLOAT:
                $newValue = filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
        }

        return $value;
    }
protected function castToType ( $ value , $ type ) { switch ( $ type ) { case self :: TYPE_CAST_INT : $ newValue = filter_var ( $ value , FILTER_VALIDATE_INT , FILTER_NULL_ON_FAILURE ) ; $ value = ( null === $ newValue ) ? $ value : $ newValue ; break ; case self :: TYPE_CAST_BOOL : $ newValue = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ; $ value = ( null === $ newValue ) ? $ value : $ newValue ; break ; case self :: TYPE_CAST_FLOAT : $ newValue = filter_var ( $ value , FILTER_VALIDATE_FLOAT , FILTER_NULL_ON_FAILURE ) ; $ value = ( null === $ newValue ) ? $ value : $ newValue ; break ; } return $ value ; }
Applies specific cast logic for each type.

@param mixed  $value Value to cast.
@param string $type  Type to cast to.

@return mixed Cast value.
Applies specific cast logic for each type .