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

Configurator   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 105
ccs 25
cts 25
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A setBaseUri() 0 4 1
A getBaseUri() 0 4 1
A addDocument() 0 16 4
A removeDocument() 0 6 2
A getDocument() 0 8 2
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 Unikorp\KongAdminApi\Document;
15
16
/**
17
 * configurator
18
 *
19
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
20
 */
21
class Configurator implements ConfiguratorInterface
22
{
23
    /**
24
     * base uri
25
     * @var string $baseUri
26
     */
27
    private $baseUri = null;
28
29
    /**
30
     * documents
31
     * @var array $documents
32
     */
33
    private $documents = [];
34
35
    /**
36
     * construct
37
     */
38 2
    public function __construct()
39
    {
40 2
        $this->documents = [
41
            'api' => Document\Api::class,
42
            'cluster' => Document\Cluster::class,
43
            'consumer' => Document\Consumer::class,
44
            'information' => Document\Information::class,
45
            'plugin' => Document\Plugin::class,
46
        ];
47 2
    }
48
49
    /**
50
     * set base uri
51
     *
52
     * @param string $baseUri
53
     *
54
     * @return void
55
     */
56 1
    public function setBaseUri($baseUri)
57
    {
58 1
        $this->baseUri = $baseUri;
59 1
    }
60
61
    /**
62
     * get base uri
63
     *
64
     * @return string $baseUri
65
     */
66 1
    public function getBaseUri()
67
    {
68 1
        return $this->baseUri;
69
    }
70
71
    /**
72
     * add document
73
     *
74
     * @param string $name
75
     * @param string $class
76
     *
77
     * @return void
78
     */
79 4
    public function addDocument($name, $class)
80
    {
81 4
        if (!empty($this->documents[$name])) {
82 1
            throw new \RuntimeException(sprintf('Document for key `%1$s` already exists', $name));
83
        }
84
85 3
        if (!is_string($class)) {
86 1
            throw new \InvalidArgumentException('Document class should be a string');
87
        }
88
89 2
        if (!class_exists($class)) {
90 1
            throw new \RuntimeException(sprintf('Document class `%1$s` does not exists', $class));
91
        }
92
93 1
        $this->documents[$name] = $class;
94 1
    }
95
96
    /**
97
     * remove document
98
     *
99
     * @param string $name
100
     *
101
     * @return false
102
     */
103 1
    public function removeDocument($name)
104
    {
105 1
        if (isset($this->documents[$name])) {
106 1
            unset($this->documents[$name]);
107
        }
108 1
    }
109
110
    /**
111
     * get document
112
     *
113
     * @param string $name
114
     *
115
     * @return string
116
     */
117 2
    public function getDocument($name)
118
    {
119 2
        if (empty($this->documents[$name])) {
120 1
            throw new \RuntimeException();
121
        }
122
123 1
        return $this->documents[$name];
124
    }
125
}
126