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 (#44)
by Martin
05:39
created

Chain   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 10
Bugs 1 Features 0
Metric Value
wmc 5
c 10
b 1
f 0
lcom 1
cbo 2
dl 0
loc 48
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getProviders() 0 4 1
A parse() 0 14 3
1
<?php
2
namespace UserAgentParser\Provider;
3
4
use UserAgentParser\Exception;
5
6
class Chain extends AbstractProvider
7
{
8
    /**
9
     * Name of the provider
10
     *
11
     * @var string
12
     */
13
    protected $name = 'Chain';
14
15
    /**
16
     *
17
     * @var AbstractProvider[]
18
     */
19
    private $providers = [];
20
21
    /**
22
     *
23
     * @param AbstractProvider[] $providers
24
     */
25 7
    public function __construct(array $providers = [])
26
    {
27 7
        $this->providers = $providers;
28 7
    }
29
30
    /**
31
     *
32
     * @return AbstractProvider[]
33
     */
34 4
    public function getProviders()
35
    {
36 4
        return $this->providers;
37
    }
38
39 3
    public function parse($userAgent, array $headers = [])
40
    {
41 3
        foreach ($this->getProviders() as $provider) {
42
            /* @var $provider \UserAgentParser\Provider\AbstractProvider */
43
44
            try {
45 2
                return $provider->parse($userAgent, $headers);
46 1
            } catch (Exception\NoResultFoundException $ex) {
47
                // just catch this and continue to the next provider
48
            }
49 2
        }
50
51 2
        throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent);
52
    }
53
}
54