/** * Return an instance with the specified HTTP protocol version. * * The version string MUST contain only the HTTP version number (e.g., * "1.1", "1.0"). * * This method MUST be implemented in such a way as to retain the * immutability of the message, and MUST return an instance that has the * new protocol version. * * @param string $version HTTP protocol version * * @return static */ public function withProtocolVersion($version) { if (!is_string($version)) { throw new \InvalidArgumentException(sprintf('Invalid version number, require string type, %s provided', gettype($version))); } if (!HeaderHelper::isValidProtocolVersion($version)) { throw new \InvalidArgumentException(sprintf('Invalid version number, require "<major>.<minor>" format, %s provided', $version)); } $new = clone $this; $new->protocol = $version; return $new; }
/** * testIsValidProtocolVersion * * @param $version * @param $expected * * @return void * * @covers \Windwalker\Http\Helper\HeaderHelper::isValidProtocolVersion * * @dataProvider isValidProtocolVersion_Provider */ public function testIsValidProtocolVersion($version, $expected) { $this->assertEquals($expected, HeaderHelper::isValidProtocolVersion($version)); }