Neomerx\JsonApi\Codec\CodecMatcher::matchEncoder PHP Method

matchEncoder() public method

public matchEncoder ( Neomerx\JsonApi\Contracts\Http\Headers\AcceptHeaderInterface $acceptHeader )
$acceptHeader Neomerx\JsonApi\Contracts\Http\Headers\AcceptHeaderInterface
    public function matchEncoder(AcceptHeaderInterface $acceptHeader)
    {
        foreach ($acceptHeader->getMediaTypes() as $headerMediaType) {
            // if quality factor 'q' === 0 it means this type is not acceptable (RFC 2616 #3.9)
            if ($headerMediaType->getQuality() > 0) {
                /** @var MediaTypeInterface $registeredType */
                foreach ($this->outputMediaTypes as list($registeredType, $closure)) {
                    if ($registeredType->matchesTo($headerMediaType) === true) {
                        $this->encoderHeaderMatchedType = $headerMediaType;
                        $this->encoderRegisteredMatchedType = $registeredType;
                        $this->foundEncoder = $closure;
                        return;
                    }
                }
            }
        }
        $this->encoderHeaderMatchedType = null;
        $this->encoderRegisteredMatchedType = null;
        $this->foundEncoder = null;
    }