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.

Client   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setToken() 0 4 1
A call() 0 19 4
A getConnection() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\MatomoBundle\Client;
13
14
use Core23\MatomoBundle\Connection\ConnectionInterface;
15
use Core23\MatomoBundle\Exception\MatomoException;
16
17
final class Client implements ClientInterface
18
{
19
    /**
20
     * @var ConnectionInterface
21
     */
22
    private $connection;
23
24
    /**
25
     * @var string
26
     */
27
    private $token;
28
29
    /**
30
     * Initialize Matomo client.
31
     *
32
     * @param ConnectionInterface $connection Matomo active connection
33
     * @param string              $token      auth token
34
     */
35
    public function __construct(ConnectionInterface $connection, string $token = 'anonymous')
36
    {
37
        $this->connection = $connection;
38
        $this->setToken($token);
39
    }
40
41
    public function setToken(string $token): void
42
    {
43
        $this->token = $token;
44
    }
45
46
    public function call(string $method, array $params = [], string $format = 'php')
47
    {
48
        $params['method']     = $method;
49
        $params['token_auth'] = $this->token;
50
        $params['format']     = $format;
51
        $data                 = $this->getConnection()->send($params);
52
53
        if ('php' === $format) {
54
            $object = unserialize($data);
55
56
            if (isset($object['result']) && 'error' === $object['result']) {
57
                throw new MatomoException($object['message']);
58
            }
59
60
            return $object;
61
        }
62
63
        return $data;
64
    }
65
66
    public function getConnection(): ConnectionInterface
67
    {
68
        return $this->connection;
69
    }
70
}
71