src/Chiron/Routing/Route.php
private function validateHttpMethods(array $methods): array
    {
        if (empty($methods)) {
            throw new InvalidArgumentException(
                'HTTP methods argument was empty; must contain at least one method'
            );
        }
        if (false === array_reduce($methods, function ($valid, $method) {
            if (false === $valid) {
                return false;
            }
            if (! is_string($method)) {
                return false;
            }
            //if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
            if (! preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method)) {
                return false;
            }

            return $valid;
        }, true)) {
            throw new InvalidArgumentException('One or more HTTP methods were invalid');
        }

        return array_map('strtoupper', $methods);
    }
private function validateHttpMethods(array $methods): array
    {
        if (empty($methods)) {
            throw new InvalidArgumentException(
                'HTTP methods argument was empty; must contain at least one method'
            );
        }
        if (false === array_reduce($methods, function ($valid, $method) {
            if (false === $valid) {
                return false;
            }
            if (! is_string($method)) {
                return false;
            }
            //if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
            if (! preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method)) {
                return false;
            }

            return $valid;
        }, true)) {
            throw new InvalidArgumentException('One or more HTTP methods were invalid');
        }

        return array_map('strtoupper', $methods);
    }
private function validateHttpMethods ( array $ methods ) : array { if ( empty ( $ methods ) ) { throw new InvalidArgumentException ( 'HTTP methods argument was empty; must contain at least one method' ) ; } if ( false === array_reduce ( $ methods , function ( $ valid , $ method ) { if ( false === $ valid ) { return false ; } if ( ! is_string ( $ method ) ) { return false ; } //if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) { if ( ! preg_match ( "/^[!#$%&'*+.^_`|~0-9a-z-]+$/i" , $ method ) ) { return false ; } return $ valid ; } , true ) ) { throw new InvalidArgumentException ( 'One or more HTTP methods were invalid' ) ; } return array_map ( 'strtoupper' , $ methods ) ; }
Validate the provided HTTP method names.

Validates, and then normalizes to upper case.

@param string[] An array of HTTP method names.

@throws Exception InvalidArgumentException for any invalid method names.

@return string[]
Validate the provided HTTP method names .