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.

PlatformConfig::loadFromArray()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
crap 3
1
<?php
2
3
namespace WebservicesNl\Platform\Webservices;
4
5
use WebservicesNl\Common\Exception\Client\InputException;
6
use WebservicesNl\Platform\AbstractConfig;
7
8
/**
9
 * Platform Config file.
10
 * Webservices config file for connecting to the Webservices Platform.
11
 */
12
class PlatformConfig extends AbstractConfig
13
{
14
    const DEFAULT_RESPONSE_TIMEOUT = 20;
15
    const PLATFORM_NAME = 'Webservices';
16
    const RETRY_MINUTES = 60;
17
18
    /**
19
     * Connection timeout in seconds.
20
     *
21
     * @var int
22
     */
23
    private $connectionTimeout = 5;
24
25
    /**
26
     * Webservices provided password (mandatory).
27
     *
28
     * @var string
29
     */
30
    private $password;
31
32
    /**
33
     * Response timeout in seconds. (Webservices specific).
34
     *
35
     * @var int
36
     */
37
    private $responseTimeout = self::DEFAULT_RESPONSE_TIMEOUT;
38
39
    /**
40
     * Threshold when to try server again after failure (in minutes).
41
     *
42
     * @var int
43
     */
44
    private $retryMinutes = self::RETRY_MINUTES;
45
46
    /**
47
     * Webservices provided username (mandatory).
48
     *
49
     * @var string
50
     */
51
    private $userName;
52
53
    /**
54
     * WebservicesConfig constructor.
55
     *
56
     * @param array $settings
57
     *
58
     * @return PlatformConfig
59
     * @throws InputException
60
     */
61 7
    public function loadFromArray(array $settings = [])
62
    {
63 7
        $settings = array_filter($settings);
64 7
        if (!array_key_exists('username', $settings) || !array_key_exists('password', $settings)) {
65 2
            throw new InputException('Not all mandatory config credentials are set');
66
        }
67 5
        $this->password = $settings['password'];
68 5
        $this->userName = $settings['username'];
69
70 5
        return $this;
71
    }
72
73
    /**
74
     * Get the connection timeout.
75
     *
76
     * @return int
77
     */
78 13
    public function getConnectionTimeout()
79
    {
80 13
        return $this->connectionTimeout;
81
    }
82
83
    /**
84
     * Set connection timeout.
85
     *
86
     * @param int $connectionTimeout
87
     */
88 8
    public function setConnectionTimeout($connectionTimeout)
89
    {
90 8
        $this->connectionTimeout = $connectionTimeout;
91 8
    }
92
93
    /**
94
     * Get the password.
95
     *
96
     * @return string
97
     */
98 15
    public function getPassword()
99
    {
100 15
        return $this->password;
101
    }
102
103
    /**
104
     * Set the password.
105
     *
106
     * @param string $password
107
     */
108 8
    public function setPassword($password)
109
    {
110 8
        $this->password = $password;
111 8
    }
112
113
    /**
114
     * Return the timeout.
115
     *
116
     * @return int
117
     */
118 13
    public function getResponseTimeout()
119
    {
120 13
        return $this->responseTimeout;
121
    }
122
123
    /**
124
     * Set response timeout.
125
     *
126
     * @param int $responseTimeout
127
     */
128 8
    public function setResponseTimeout($responseTimeout)
129
    {
130 8
        $this->responseTimeout = $responseTimeout;
131 8
    }
132
133
    /**
134
     * Return the retry minutes.
135
     *
136
     * @return int
137
     */
138 13
    public function getRetryMinutes()
139
    {
140 13
        return $this->retryMinutes;
141
    }
142
143
    /**
144
     * set retryMinutes.
145
     *
146
     * @param int $retryMinutes
147
     */
148 8
    public function setRetryMinutes($retryMinutes)
149
    {
150 8
        $this->retryMinutes = $retryMinutes;
151 8
    }
152
153
    /**
154
     * Return the username.
155
     *
156
     * @return string
157
     */
158 15
    public function getUserName()
159
    {
160 15
        return $this->userName;
161
    }
162
163
    /**
164
     * Set username.
165
     *
166
     * @param string $userName
167
     */
168 8
    public function setUserName($userName)
169
    {
170 8
        $this->userName = $userName;
171 8
    }
172
173
    /**
174
     * {@inheritdoc}
175
     *
176
     * @return array
177
     */
178 10
    public function toArray()
179
    {
180 10
        return array_filter(
181
            [
182 10
                'connectionTimeout' => $this->getConnectionTimeout(),
183 10
                'password'          => $this->getPassword(),
184 10
                'responseTimeout'   => $this->getResponseTimeout(),
185 10
                'retryMinutes'      => $this->getRetryMinutes(),
186 10
                'userName'          => $this->getUserName(),
187
            ]
188 10
        );
189
    }
190
191
    /**
192
     * {@inheritdoc}
193
     *
194
     * @return string
195
     */
196 4
    public function getConnectorName()
197
    {
198 4
        return __NAMESPACE__ . '\Connector';
199
    }
200
}
201