Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed May 4, 2017
1 parent a544fb9 commit 9556d08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/Negotiation/AbstractNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getBest($header, array $priorities, $strict = false)
}

/**
* @param string $header A string containing an `Accept|Accept-*` header.
* @param string $header A string containing an `Accept|Accept-*` header.
*
* @return [AcceptHeader] An ordered list of accept header elements
*/
Expand All @@ -74,18 +74,18 @@ public function getOrderedElements($header)
// silently skip in case of invalid headers coming in from a client
}
}

// sort based on quality and then original order. This is necessary as
// to ensure that the first in the list for two items with the same
// quality stays in that order in both PHP5 and PHP7.
uasort($orderKeys, function ($a, $b) {
$qA = $a[0];
$qB = $b[0];

if ($qA == $qB) {
return $a[1] > $b[1];
}

return ($qA > $qB) ? -1 : 1;
});

Expand All @@ -97,7 +97,6 @@ public function getOrderedElements($header)
return $orderedElements;
}


/**
* @param string $header accept header part or server priority
*
Expand Down
4 changes: 3 additions & 1 deletion tests/Negotiation/Tests/NegotiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ public function testGetOrderedElements($header, $expected)
$elements = $this->negotiator->getOrderedElements($header);
} catch (\Exception $e) {
$this->assertEquals($expected, $e);

return;
}

if (empty($elements)) {
$this->assertNull($expected);

return;
}

Expand All @@ -133,7 +135,7 @@ public static function dataProviderForTestGetOrderedElements()

// first one wins as no quality modifiers
array('text/html, text/xml', array('text/html', 'text/xml')),

// ordered by quality modifier
array(
'text/html;q=0.3, text/html;q=0.7',
Expand Down

0 comments on commit 9556d08

Please sign in to comment.