protected function castToScalar($value, $type)
    {
        if ($type === 'integer') {
            return (integer) $value;
        }
        if ($type === 'boolean') {
            return (boolean) $value;
        }
        if ($type === 'float') {
            return (float) $value;
        }
        if ($type === 'string') {
            return (string) $value;
        }

        return $value;
    }