Zend\Diactoros\MessageTrait::validateProtocolVersion PHP Method

validateProtocolVersion() private method

Validate the HTTP protocol version
private validateProtocolVersion ( string $version )
$version string
    private function validateProtocolVersion($version)
    {
        if (empty($version)) {
            throw new InvalidArgumentException(sprintf('HTTP protocol version can not be empty'));
        }
        if (!is_string($version)) {
            throw new InvalidArgumentException(sprintf('Unsupported HTTP protocol version; must be a string, received %s', is_object($version) ? get_class($version) : gettype($version)));
        }
        // HTTP/1 uses a "<major>.<minor>" numbering scheme to indicate
        // versions of the protocol, while HTTP/2 does not.
        if (!preg_match('#^(1\\.[01]|2)$#', $version)) {
            throw new InvalidArgumentException(sprintf('Unsupported HTTP protocol version "%s" provided', $version));
        }
    }