protected function castValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($this->isElementOfDate() && $this->isDateCastable()) {
            return $this->fromDateTime($value);
        }

        switch ($this->getCast()) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'object':
                return $this->fromJson($value, true);
            case 'array':
            case 'json':
                return $this->fromJson($value);
            case 'collection':
                return new Collection($this->fromJson($value));
            case 'comma':
                return $this->fromCommaSeparated($value);
            default:
                return $value;
        }
    }
protected function castValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($this->isElementOfDate() && $this->isDateCastable()) {
            return $this->fromDateTime($value);
        }

        switch ($this->getCast()) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'object':
                return $this->fromJson($value, true);
            case 'array':
            case 'json':
                return $this->fromJson($value);
            case 'collection':
                return new Collection($this->fromJson($value));
            case 'comma':
                return $this->fromCommaSeparated($value);
            default:
                return $value;
        }
    }
protected function castValue ( $ value ) { if ( is_null ( $ value ) ) { return $ value ; } if ( $ this -> isElementOfDate ( ) && $ this -> isDateCastable ( ) ) { return $ this -> fromDateTime ( $ value ) ; } switch ( $ this -> getCast ( ) ) { case 'int' : case 'integer' : return ( int ) $ value ; case 'real' : case 'float' : case 'double' : return ( float ) $ value ; case 'string' : return ( string ) $ value ; case 'bool' : case 'boolean' : return ( bool ) $ value ; case 'object' : return $ this -> fromJson ( $ value , true ) ; case 'array' : case 'json' : return $ this -> fromJson ( $ value ) ; case 'collection' : return new Collection ( $ this -> fromJson ( $ value ) ) ; case 'comma' : return $ this -> fromCommaSeparated ( $ value ) ; default : return $ value ; } }
Cast a value to a native PHP type.

@param $value
@return array
Cast a value to a native PHP type .