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:01
created

Client::addPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 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 Http\Message\MessageFactory;
22
23
/**
24
 * client
25
 *
26
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
27
 */
28
class Client
29
{
30
    /**
31
     * http client
32
     * @var \Http\Client\HttpClient $httpClient
33
     */
34
    private $httpClient = null;
35
36
    /**
37
     * message factory
38
     * @var \Http\Message\MessageFactory $messageFactory
39
     */
40
    private $messageFactory = null;
41
42
    /**
43
     * plugins
44
     * @var array $plugins
45
     */
46
    private $plugins = [];
47
48
    /**
49
     * constructor
50
     *
51
     * @param string $baseUri
52
     * @param \Http\Client\HttpClient $httpClient
53
     */
54
    public function __construct($baseUri, HttpClient $httpClient = null)
55
    {
56
        $this->httpClient = $httpClient ?: HttpClientDiscovery::find();
57
        $this->messageFactory = MessageFactoryDiscovery::find();
58
59
        $this->addPlugin(
60
            new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri($baseUri))
61
        );
62
    }
63
64
    /**
65
     * api
66
     *
67
     * @param string $name
68
     *
69
     * @return \Unikorp\KongAdminApi\ApiInterface
70
     *
71
     * @throws \InvalidArgumentException
72
     */
73
    public function api($name)
74
    {
75
        switch ($name) {
76
            default:
0 ignored issues
show
Unused Code introduced by
default: throw new \...e called: %s', $name)); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
77
                throw new \InvalidArgumentException(sprintf('Undefined api instance called: %s', $name));
78
        }
79
    }
80
81
    /**
82
     * add plugin
83
     *
84
     * @param \Http\Client\Common\Plugin $plugin
85
     *
86
     * @return void
87
     */
88
    public function addPlugin(Plugin $plugin)
89
    {
90
        $this->plugins[] = $plugin;
91
    }
92
93
    /**
94
     * get http client
95
     *
96
     * @return \Http\Client\Common\HttpMethodsClient
97
     */
98
    public function getHttpClient()
99
    {
100
        return new HttpMethodsClient(
101
            new PluginClient($this->httpClient, $this->plugins),
102
            $this->messageFactory
103
        );
104
    }
105
}
106