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.

Chain   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

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