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   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 37
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A acceptFactory() 0 4 1
C match() 0 23 7
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