GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Match::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Negotiation;
4
5
final class Match
6
{
7
    /**
8
     * @var float
9
     */
10
    public $quality;
11
12
    /**
13
     * @var int
14
     */
15
    public $score;
16
17
    /**
18
     * @var int
19
     */
20
    public $index;
21
22 61
    public function __construct($quality, $score, $index)
23
    {
24 61
        $this->quality = $quality;
25 61
        $this->score   = $score;
26 61
        $this->index   = $index;
27 61
    }
28
29
    /**
30
     * @param Match $a
31
     * @param Match $b
32
     *
33
     * @return int
34
     */
35 35
    public static function compare(Match $a, Match $b)
36
    {
37 35
        if ($a->quality !== $b->quality) {
38 28
            return $a->quality > $b->quality ? -1 : 1;
39
        }
40
41 9
        if ($a->index !== $b->index) {
42 8
            return $a->index > $b->index ? 1 : -1;
43
        }
44
45 1
        return 0;
46
    }
47
48
    /**
49
     * @param array $carry reduced array
50
     * @param Match $match match to be reduced
51
     *
52
     * @return Match[]
53
     */
54 61
    public static function reduce(array $carry, Match $match)
55
    {
56 61
        if (!isset($carry[$match->index]) || $carry[$match->index]->score < $match->score) {
57 60
            $carry[$match->index] = $match;
58 60
        }
59
60 61
        return $carry;
61
    }
62
}
63