LazyRecord\Schema\RuntimeColumn::typeCasting PHP Method

typeCasting() public method

Column value type casting for input values.
public typeCasting ( mixed $value ) : mixed
$value mixed referenced value
return mixed
    public function typeCasting($value)
    {
        if ($value instanceof Raw) {
            return $value;
        }
        if ($isa = $this->isa) {
            if ($isa === 'int') {
                return intval($value);
            } elseif ($isa === 'str') {
                return (string) $value;
            } elseif ($isa === 'DateTime') {
                if ($value === '' || $value === 0 || $value === false) {
                    return;
                }
            } elseif ($isa === 'bool') {
                if ($value === null) {
                    return;
                }
                if ($value === '') {
                    return;
                } else {
                    return filter_var($value, FILTER_VALIDATE_BOOLEAN, array('flags' => FILTER_NULL_ON_FAILURE));
                }
                return $value;
            }
        }
        return $value;
    }