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.
Completed
Pull Request — master (#78)
by
unknown
05:26
created

LanguageNegotiator   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 93.75%
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 38
ccs 15
cts 16
cp 0.9375
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A acceptFactory() 0 4 1
C match() 0 24 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)) {
34 8
            $score = 10 * $baseEqual + $subEqual;
35 8
            $q = ($as === null || $subEqual) ? 1 : 0.1;
36
37 8
            return new Match($acceptLanguage->getQuality() * $q, $score, $index);
38
        }
39
40 10
        return null;
41
    }
42
}
43