/** * Negotiate the accept header. * * @param $conf Configuration the negotiation configuration * @param $headerLine string the accept header * @return BaseAccept|null negotiation result * @return NegotiationException negotiation error */ private function handleInput(Configuration $conf, $headerLine) { $priorities = $conf->getPriorities(); $negotiator = $conf->getNegotiator(); try { // returns negotiation result or null return $negotiator->getBest($headerLine, $priorities); } catch (RuntimeException $e) { throw new NegotiationException('negotiator error', $e); } }
function testGetters() { $headerName = 'the name'; $negotiator = new LanguageNegotiator(); $priorities = ['one', 'two']; $acceptFactory = function () { }; $c = new Configuration(); $c->setHeaderName($headerName); $c->setPriorities($priorities); $c->setNegotiator($negotiator); $c->setAcceptFactory($acceptFactory); $this->assertSame($headerName, $c->getHeaderName()); $this->assertSame($negotiator, $c->getNegotiator()); $this->assertSame($priorities, $c->getPriorities()); }