<?php namespace Negotiation; final class AcceptMatch { /** * @var float */ public $quality; /** * @var int */ public $score; /** * @var int */ public $index; public function __construct($quality, $score, $index) { $this->quality = $quality; $this->score = $score; $this->index = $index; } /** * @param AcceptMatch $a * @param AcceptMatch $b * * @return int */ public static function compare(AcceptMatch $a, AcceptMatch $b) { if ($a->quality !== $b->quality) { return $a->quality > $b->quality ? -1 : 1; } if ($a->index !== $b->index) { return $a->index > $b->index ? 1 : -1; } return 0; } /** * @param array $carry reduced array * @param AcceptMatch $match match to be reduced * * @return AcceptMatch[] */ public static function reduce(array $carry, AcceptMatch $match) { if (!isset($carry[$match->index]) || $carry[$match->index]->score < $match->score) { $carry[$match->index] = $match; } return $carry; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Exception | Folder | 0755 |
|
|
AbstractNegotiator.php | File | 5 KB | 0644 |
|
Accept.php | File | 825 B | 0644 |
|
AcceptCharset.php | File | 104 B | 0644 |
|
AcceptEncoding.php | File | 105 B | 0644 |
|
AcceptHeader.php | File | 58 B | 0644 |
|
AcceptLanguage.php | File | 1.04 KB | 0644 |
|
AcceptMatch.php | File | 1.17 KB | 0644 |
|
BaseAccept.php | File | 2.95 KB | 0644 |
|
CharsetNegotiator.php | File | 224 B | 0644 |
|
EncodingNegotiator.php | File | 226 B | 0644 |
|
LanguageNegotiator.php | File | 1.05 KB | 0644 |
|
Match.php | File | 1.12 KB | 0644 |
|
Negotiator.php | File | 2.81 KB | 0644 |
|