public function parseField($value, string $fieldType)
    {
        // Uses $fieldType method of the schema to parse the value
        if (method_exists($this->schema, $fieldType)) {
            return $this->schema->$fieldType($value);
        }

        // Returns null or an empty array
        if (null === $value || is_array($value) && empty($value)) {
            return $value;
        }

        // If fieldType is castable (Ex: 'int')
        if (in_array($fieldType, $this->castableTypes)) {
            return $this->cast($value, $fieldType);
        }

        // If the field type points to another schema.
        if ('schema.' == substr($fieldType, 0, 7)) {
            return $this->mapToSchema($value, substr($fieldType, 7));
        }

        return $value;
    }
public function parseField($value, string $fieldType)
    {
        // Uses $fieldType method of the schema to parse the value
        if (method_exists($this->schema, $fieldType)) {
            return $this->schema->$fieldType($value);
        }

        // Returns null or an empty array
        if (null === $value || is_array($value) && empty($value)) {
            return $value;
        }

        // If fieldType is castable (Ex: 'int')
        if (in_array($fieldType, $this->castableTypes)) {
            return $this->cast($value, $fieldType);
        }

        // If the field type points to another schema.
        if ('schema.' == substr($fieldType, 0, 7)) {
            return $this->mapToSchema($value, substr($fieldType, 7));
        }

        return $value;
    }
public function parseField ( $ value , string $ fieldType ) { // Uses $fieldType method of the schema to parse the value if ( method_exists ( $ this -> schema , $ fieldType ) ) { return $ this -> schema -> $ fieldType ( $ value ) ; } // Returns null or an empty array if ( null === $ value || is_array ( $ value ) && empty ( $ value ) ) { return $ value ; } // If fieldType is castable (Ex: 'int') if ( in_array ( $ fieldType , $ this -> castableTypes ) ) { return $ this -> cast ( $ value , $ fieldType ) ; } // If the field type points to another schema. if ( 'schema.' == substr ( $ fieldType , 0 , 7 ) ) { return $ this -> mapToSchema ( $ value , substr ( $ fieldType , 7 ) ) ; } return $ value ; }
Parse a value based on a field yype of the schema.

@param mixed  $value     value to be parsed
@param string $fieldType description of how the field should be treated

@return mixed $value Value parsed to match $type
Parse a value based on a field yype of the schema .