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 (#2)
by VEBER
02:36
created

Client   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 8

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getNode() 0 6 1
A addPlugin() 0 4 1
A getHttpClient() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the KongAdminApi package.
5
 *
6
 * (c) Unikorp <https://github.com/unikorp>
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 Unikorp\KongAdminApi;
13
14
use Http\Client\Common\HttpMethodsClient;
15
use Http\Client\Common\Plugin;
16
use Http\Client\Common\PluginClient;
17
use Http\Client\HttpClient;
18
use Http\Discovery\HttpClientDiscovery;
19
use Http\Discovery\MessageFactoryDiscovery;
20
use Http\Discovery\UriFactoryDiscovery;
21
22
/**
23
 * client
24
 *
25
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
26
 */
27
class Client
28
{
29
    /**
30
     * configurator
31
     * @var \Unikorp\KongAdminApi\ConfiguratorInterface $configurator
32
     */
33
    private $configurator = null;
34
35
    /**
36
     * http client
37
     * @var \Http\Client\HttpClient $httpClient
38
     */
39
    private $httpClient = null;
40
41
    /**
42
     * message factory
43
     * @var \Http\Message\MessageFactory $messageFactory
44
     */
45
    private $messageFactory = null;
46
47
    /**
48
     * plugins
49
     * @var array $plugins
50
     */
51
    private $plugins = [];
52
53
    /**
54
     * constructor
55
     *
56
     * @param \Unikorm\KongAdminApi\ConfiguratorInterface $configurator
57
     * @param \Http\Client\HttpClient $httpClient
58
     */
59 3
    public function __construct(ConfiguratorInterface $configurator, HttpClient $httpClient = null)
60
    {
61 3
        $this->configurator = $configurator;
62
63 3
        $this->httpClient = $httpClient ?: HttpClientDiscovery::find();
64 3
        $this->messageFactory = MessageFactoryDiscovery::find();
65
66 3
        $this->plugins[] = new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri($configurator->getBaseUri()));
67 3
    }
68
69
    /**
70
     * get node
71
     *
72
     * @param string $name
73
     *
74
     * @return \Unikorp\KongAdminApi\NodeInterface
75
     */
76 6
    public function getNode($name)
77
    {
78 6
        $node = $this->configurator->getNode($name);
79
80 5
        return new $node($this);
81
    }
82
83
    /**
84
     * add plugin
85
     *
86
     * @param \Http\Client\Common\Plugin $plugin
87
     *
88
     * @return void
89
     */
90 1
    public function addPlugin(Plugin $plugin)
91
    {
92 1
        $this->plugins[] = $plugin;
93 1
    }
94
95
    /**
96
     * get http client
97
     *
98
     * @return \Http\Client\Common\HttpMethodsClient
99
     */
100 1
    public function getHttpClient()
101
    {
102 1
        return new HttpMethodsClient(
103 1
            new PluginClient($this->httpClient, $this->plugins),
104 1
            $this->messageFactory
105
        );
106
    }
107
}
108