private function createConfiguration($headerName, array $priorities = [''])
 {
     $conf = new Configuration();
     $conf->setHeaderName($headerName);
     $conf->setPriorities($priorities);
     return $conf;
 }
 /**
  * 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);
     }
 }
 /**
  * Create an instance of Configuration.
  *
  * @param $headerName       string          name of accept header
  * @param $priorities       array[string]   list of accepted values sorted by
  *                                          priority (first has highest)
  * @return Configuration
  */
 public function create($headerName, array $priorities)
 {
     $negotiator = $this->createNegotiator($headerName);
     $acceptFactory = $this->createAcceptFactory($headerName);
     $c = new Configuration();
     $c->setHeaderName($headerName);
     $c->setPriorities($priorities);
     $c->setNegotiator($negotiator);
     $c->setAcceptFactory($acceptFactory);
     return $c;
 }
 /**
  * @expectedException   \InvalidArgumentException
  */
 function testEmptyPriorities()
 {
     $c = new Configuration();
     $c->setPriorities([]);
 }