/** * Create a header field instance from a mapping class. * @param string $headerFieldName * @param string $headerFieldValue * @throws \Brickoo\Component\Http\Header\Aggregator\Exception\HeaderFieldClassNotFoundException * @return \Brickoo\Component\Http\HttpHeaderField */ private function createMappingHeaderField($headerFieldName, $headerFieldValue) { try { $headerFieldClass = $this->headerFieldClassMap->getClass($headerFieldName); if (!class_exists($headerFieldClass)) { throw new \Exception("Unable to load mapping header class."); } } catch (\Exception $exception) { throw new HeaderFieldClassNotFoundException($headerFieldName, $exception); } return new $headerFieldClass($headerFieldValue); }
/** * @covers Brickoo\Component\Http\Header\Aggregator\HeaderFieldClassMap::getClass * @covers Brickoo\Component\Http\Header\Aggregator\HeaderFieldClassMap::hasClass */ public function testGetFieldClass() { $classMap = new HeaderFieldClassMap(); $this->assertEquals("Brickoo\\Component\\Http\\Header\\AcceptHeaderField", $classMap->getClass("Accept")); }