Clickalicious\PhpMemAdmin\App::castAsPhpType PHP Метод

castAsPhpType() защищенный Метод

Returns the value casted to a native PHP type.
Автор: Benjamin Carl ([email protected])
protected castAsPhpType ( mixed $value ) : mixed
$value mixed The value to cast magically.
Результат mixed The resulting value
    protected function castAsPhpType($value)
    {
        // We only check string values for type - object and array not - and double and int can keep as they are.
        if (is_string($value) === true && is_numeric($value) === true) {
            // Try to map a string or some similar type of a real type in PHP
            // Try INT
            if ((int) $value . "" === $value) {
                $value = (int) $value;
                // Try DOUBLE
            } elseif ((double) $value . "" === $value) {
                $value = (double) $value;
                // Try BOOL
            } elseif ((bool) $value . "" === $value) {
                $value = (bool) $value;
            }
        }
        return $value;
    }