protected function castToScalar($value, $type)
    {
        if ($type === 'integer') {
            return (integer) $value;
        }
        if ($type === 'boolean') {
            return (boolean) $value;
        }
        if ($type === 'float') {
            return (float) $value;
        }
        if ($type === 'string') {
            return (string) $value;
        }

        return $value;
    }
protected function castToScalar($value, $type)
    {
        if ($type === 'integer') {
            return (integer) $value;
        }
        if ($type === 'boolean') {
            return (boolean) $value;
        }
        if ($type === 'float') {
            return (float) $value;
        }
        if ($type === 'string') {
            return (string) $value;
        }

        return $value;
    }
protected function castToScalar ( $ value , $ type ) { if ( $ type === 'integer' ) { return ( integer ) $ value ; } if ( $ type === 'boolean' ) { return ( boolean ) $ value ; } if ( $ type === 'float' ) { return ( float ) $ value ; } if ( $ type === 'string' ) { return ( string ) $ value ; } return $ value ; }
Cast a value to the desired scalar type. Value remains unchanged if type is not scalar.

@param mixed  $value The value you went to cast
@param string $type  The type you want to cast to

@return mixed
Cast a value to the desired scalar type . Value remains unchanged if type is not scalar .