src/CRUDlex/Entity.php
protected function toType($value, $type)
    {
        if (in_array($type, ['integer', 'float']) && !in_array($value, ['', null], true)) {
            settype($value, $type);
        } else if ($type == 'boolean') {
            $value = (bool)$value;
        } else if ($type == 'many') {
            $value = $value ?: [];
        }
        return $value === '' ? null : $value;
    }
protected function toType($value, $type)
    {
        if (in_array($type, ['integer', 'float']) && !in_array($value, ['', null], true)) {
            settype($value, $type);
        } else if ($type == 'boolean') {
            $value = (bool)$value;
        } else if ($type == 'many') {
            $value = $value ?: [];
        }
        return $value === '' ? null : $value;
    }
protected function toType ( $ value , $ type ) { if ( in_array ( $ type , [ 'integer' , 'float' ] ) && ! in_array ( $ value , [ '' , null ] , true ) ) { settype ( $ value , $ type ) ; } else if ( $ type == 'boolean' ) { $ value = ( bool ) $ value ; } else if ( $ type == 'many' ) { $ value = $ value ? : [ ] ; } return $ value === '' ? null : $ value ; }
Converts a given value to the given type.

@param mixed $value
the value to convert
@param string $type
the type to convert to like 'integer' or 'float'

@return mixed
the converted value
Converts a given value to the given type .