protected function cast($value = null, int $type = Variables::TYPE_STRING)
    {
        if ($value === null) {
            return $this->getDefault($type);
        }
        switch ($type) {
            case Variables::TYPE_INT:
                $value = @\intval($value);
                break;
            case Variables::TYPE_FLOAT:
                $value = @\floatval($value);
                break;
            case Variables::TYPE_STRING:
                $value = @\strval($value);
                break;
            case Variables::TYPE_ARRAY:
                $value = (array)$value;
                break;
            case Variables::TYPE_JSON_DECODED:
                $value = @\json_decode(@\strval($value), true, 512) ?: '';
                break;
            case Variables::TYPE_AUTO:
                break;
            default:
                throw new DomainException('Invalid variable type specified');
                break;
        }
        return $value;
    }