protected function castToType($value, $property)
    {
        $type = $this->getPropertyType($property);

        switch ($type) {
            case 'array':
                return is_array($value) ? $value : explode(",", $value);
            case 'bool':
            case 'boolean':
                return (boolean) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'string':
                return (string) $value;
            default:
                return $value;
        }
    }
protected function castToType($value, $property)
    {
        $type = $this->getPropertyType($property);

        switch ($type) {
            case 'array':
                return is_array($value) ? $value : explode(",", $value);
            case 'bool':
            case 'boolean':
                return (boolean) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'string':
                return (string) $value;
            default:
                return $value;
        }
    }
protected function castToType ( $ value , $ property ) { $ type = $ this -> getPropertyType ( $ property ) ; switch ( $ type ) { case 'array' : return is_array ( $ value ) ? $ value : explode ( "," , $ value ) ; case 'bool' : case 'boolean' : return ( boolean ) $ value ; case 'int' : case 'integer' : return ( int ) $ value ; case 'string' : return ( string ) $ value ; default : return $ value ; } }
Cast a given property value to the matching property type

@param mixed  $value
@param string $property

@return boolean|number|string|integer
@throws \ReflectionException
Cast a given property value to the matching property type