Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
29 | 3 | protected function collect(BaseHeaderValue $value): void |
|
30 | { |
||
31 | 3 | if (count($this->collection) === 0) { |
|
32 | 3 | $this->collection[] = $value; |
|
33 | 3 | return; |
|
34 | } |
||
35 | 2 | for ($pos = array_key_last($this->collection); $pos >= 0; --$pos) { |
|
36 | 2 | $item = $this->collection[$pos]; |
|
37 | 2 | $result = (float)$item->getQuality() <=> (float)$value->getQuality(); |
|
|
|||
38 | 2 | if ($result >= 0) { |
|
39 | 2 | $this->collection[$pos + 1] = $value; |
|
40 | 2 | return; |
|
41 | } |
||
42 | 2 | $this->collection[$pos + 1] = $item; |
|
43 | } |
||
44 | 2 | $this->collection[0] = $value; |
|
45 | 2 | } |
|
47 |