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
Push — master ( beaba1...b637a0 )
by VEBER
17s
created

Client   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 8

Test Coverage

Coverage 100%

Importance

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

4 Methods

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