private static function get(string $resourceName, string $name, string $default = null, array $allowedValues = null)
    {
        switch ($resourceName) {
            case 'GET':
                $resource = $_GET;
                break;

            case 'POST':
                if (!isset($_POST)) {
                    return $default;
                }

                $resource = $_POST;
                break;

            case 'PUT':
                if ($_SERVER['REQUEST_METHOD'] !== 'PUT') {
                    return $default;
                }

                $resource = static::getInputVars();
                break;

            case 'DELETE':
                if ($_SERVER['REQUEST_METHOD'] !== 'DELETE') {
                    return $default;
                }

                $resource = static::getInputVars();
                break;

            default:
                throw new RequestException("Invalid resource name={$resourceName}");
                break;
        }

        if (array_key_exists($name, $resource)) {

            if (is_array($resource[$name])) {
                return $resource[$name];
            }

            $value = trim($resource[$name]);

            if ($value == '') {
                return $default;
            }

            if ($allowedValues !== null) {
                return (in_array($value, $allowedValues)) ? $value : $default;
            }

            return $value;
        } else {
            return $default;
        }
    }