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.

LanguageNegotiator::match()   C
last analyzed

Complexity

Conditions 7
Paths 3

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 7.0222

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 12
cts 13
cp 0.9231
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 13
nc 3
nop 3
crap 7.0222
1
<?php
2
3
namespace Negotiation;
4
5
class LanguageNegotiator extends AbstractNegotiator
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10 10
    protected function acceptFactory($accept)
11
    {
12 10
        return new AcceptLanguage($accept);
13
    }
14
15
    /**
16
     * {@inheritdoc}
17
     */
18 10
    protected function match(AcceptHeader $acceptLanguage, AcceptHeader $priority, $index)
19
    {
20 10
        if (!$acceptLanguage instanceof AcceptLanguage || !$priority instanceof AcceptLanguage) {
21
            return null;
22
        }
23
24 10
        $ab = $acceptLanguage->getBasePart();
25 10
        $pb = $priority->getBasePart();
26
27 10
        $as = $acceptLanguage->getSubPart();
28 10
        $ps = $priority->getSubPart();
29
30 10
        $baseEqual = !strcasecmp($ab, $pb);
31 10
        $subEqual  = !strcasecmp($as, $ps);
32
33 10
        if (($ab == '*' || $baseEqual) && ($as === null || $subEqual)) {
34 8
            $score = 10 * $baseEqual + $subEqual;
35
36 8
            return new Match($acceptLanguage->getQuality() * $priority->getQuality(), $score, $index);
37
        }
38
39 10
        return null;
40
    }
41
}
42