Inheritance: extends Header, implements Neomerx\JsonApi\Contracts\Http\Headers\AcceptHeaderInterface
Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function parse(ServerRequestInterface $request)
 {
     $acceptHeader = null;
     $contentTypeHeader = null;
     $method = $request->getMethod();
     try {
         $header = $this->getHeader($request, HeaderInterface::HEADER_CONTENT_TYPE);
         $contentTypeHeader = Header::parse($header, HeaderInterface::HEADER_CONTENT_TYPE);
     } catch (InvalidArgumentException $exception) {
         E::throwException(new E([], E::HTTP_CODE_BAD_REQUEST, $exception));
     }
     try {
         $header = $this->getHeader($request, HeaderInterface::HEADER_ACCEPT);
         $acceptHeader = AcceptHeader::parse($header);
     } catch (InvalidArgumentException $exception) {
         E::throwException(new E([], E::HTTP_CODE_BAD_REQUEST, $exception));
     }
     return $this->factory->createHeaderParameters($method, $acceptHeader, $contentTypeHeader);
 }
 /**
  * @depends testCodecMatcher
  */
 public function testEncoderC()
 {
     $codecMatcher = $this->repository->getCodecMatcher();
     $codecMatcher->matchEncoder(AcceptHeader::parse(static::C));
     $this->assertEquals($this->encoderC, $codecMatcher->getEncoder());
     $this->assertEquals(static::C, $codecMatcher->getEncoderHeaderMatchedType()->getMediaType());
     $this->assertEquals(static::C, $codecMatcher->getEncoderRegisteredMatchedType()->getMediaType());
 }