CrudKit\Data\SQL\SQLColumn::cleanValue PHP Method

cleanValue() public method

public cleanValue ( $value )
    public function cleanValue($value)
    {
        switch ($this->typeName) {
            case "number":
                return floatval($value);
                break;
            case "string":
                return "" . $value;
                break;
            case "datetime":
                $timezone = isset($this->options['timezone']) ? $this->options['timezone'] : "UTC";
                // Assuming that the value that client has given is in UTC
                $timeObject = Carbon::createFromTimestamp(intval($value), "UTC");
                // Now convert this into the target timezone
                $timeObject->setTimezone($timezone);
                return $timeObject;
                break;
            case "date":
                $date = date_create($value);
                $date = date_format($date, 'm-d-Y');
                return $date;
                break;
            default:
                throw new \Exception("Unknown type {$this->typeName}");
        }
    }