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 ( b04e0b...0f07bb )
by Sergey
02:50
created

Environment::getQueryType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * This file is part of the reva2/jsonapi.
4
 *
5
 * (c) Sergey Revenko <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
12
namespace Reva2\JsonApi\Services;
13
14
use Neomerx\JsonApi\Contracts\Encoder\EncoderInterface;
15
use Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface;
16
use Reva2\JsonApi\Contracts\Decoders\DecoderInterface;
17
use Reva2\JsonApi\Contracts\Services\EnvironmentInterface;
18
19
/**
20
 * JSON API environment
21
 *
22
 * @package Reva2\JsonApi\Services
23
 * @author Sergey Revenko <[email protected]>
24
 */
25
class Environment implements EnvironmentInterface
26
{
27
    /**
28
     * Expected query parameters type
29
     *
30
     * @var string|null
31
     */
32
    protected $queryType;
33
34
    /**
35
     * Expected body content type
36
     *
37
     * @var string|null
38
     */
39
    protected $bodyType;
40
41
    /**
42
     * Codec matcher configuration
43
     *
44
     * @var array
45
     */
46
    protected $matcherConfiguration;
47
48
    /**
49
     * URLs prefix
50
     *
51
     * @var string
52
     */
53
    protected $urlPrefix = '';
54
55
    /**
56
     * Serialization groups
57
     *
58
     * @var string[]
59
     */
60
    protected $serializationGroups = ['Default'];
61
62
    /**
63
     * Validation groups
64
     *
65
     * @var string[]|null
66
     */
67
    protected $validationGroups;
68
69
    /**
70
     * Request decoder
71
     *
72
     * @var DecoderInterface|null
73
     */
74
    protected $decoder;
75
76
    /**
77
     * Response encoder
78
     *
79
     * @var EncoderInterface|null
80
     */
81
    protected $encoder;
82
83
    /**
84
     * Response encoder media type
85
     *
86
     * @var MediaTypeInterface|null
87
     */
88
    protected $encoderMediaType;
89
90
    /**
91
     * Constructor
92
     *
93
     * @param array|null $config
94
     */
95 5
    public function __construct(array $config = null)
96
    {
97 5
        if (null !== $config) {
98 1
            $this->fromArray($config);
99
        }
100 5
    }
101
102
    /**
103
     * @inheritdoc
104
     */
105 3
    public function getQueryType()
106
    {
107 3
        return $this->queryType;
108
    }
109
110
    /**
111
     * Sets expected query parameters type
112
     *
113
     * @param null|string $queryType
114
     * @return $this
115
     */
116 2
    public function setQueryType($queryType = null)
117
    {
118 2
        $this->queryType = $queryType;
119
120 2
        return $this;
121
    }
122
123
    /**
124
     * @inheritdoc
125
     */
126 3
    public function getBodyType()
127
    {
128 3
        return $this->bodyType;
129
    }
130
131
    /**
132
     * Sets expected body content type
133
     *
134
     * @param null|string $bodyType
135
     * @return $this
136
     */
137 1
    public function setBodyType($bodyType = null)
138
    {
139 1
        $this->bodyType = $bodyType;
140
141 1
        return $this;
142
    }
143
144
    /**
145
     * @inheritdoc
146
     */
147 4
    public function getMatcherConfiguration()
148
    {
149 4
        return $this->matcherConfiguration;
150
    }
151
152
    /**
153
     * Sets codec matcher configuration
154
     *
155
     * @param array $matcherConfiguration
156
     * @return $this
157
     */
158 5
    public function setMatcherConfiguration(array $matcherConfiguration)
159
    {
160 5
        $this->matcherConfiguration = $matcherConfiguration;
161
162 5
        return $this;
163
    }
164
165
    /**
166
     * @inheritdoc
167
     */
168
    public function getUrlPrefix()
169
    {
170
        return $this->urlPrefix;
171
    }
172
173
    /**
174
     * Sets URLs prefix
175
     *
176
     * @param string $urlPrefix
177
     * @return $this
178
     */
179 1
    public function setUrlPrefix($urlPrefix)
180
    {
181 1
        $this->urlPrefix = $urlPrefix;
182
183 1
        return $this;
184
    }
185
186
    /**
187
     * @return string[]
188
     */
189 3
    public function getSerializationGroups()
190
    {
191 3
        return $this->serializationGroups;
192
    }
193
194
    /**
195
     * @param string[] $serializationGroups
196
     * @return $this
197
     */
198 1
    public function setSerializationGroups(array $serializationGroups)
199
    {
200 1
        $this->serializationGroups = $serializationGroups;
201
202 1
        return $this;
203
    }
204
205
    /**
206
     * @inheritdoc
207
     */
208 3
    public function getValidationGroups()
209
    {
210 3
        return $this->validationGroups;
211
    }
212
213
    /**
214
     * Sets validation groups
215
     *
216
     * @param array|null $validationGroups
217
     * @return $this
218
     */
219 4
    public function setValidationGroups(array $validationGroups = null)
220
    {
221 4
        $this->validationGroups = $validationGroups;
222
223 4
        return $this;
224
    }
225
226
    /**
227
     * @inheritdoc
228
     */
229 1
    public function getEncoder()
230
    {
231 1
        return $this->encoder;
232
    }
233
234
    /**
235
     * Sets response encoder
236
     *
237
     * @param EncoderInterface $encoder
238
     * @return $this
239
     */
240 3
    public function setEncoder(EncoderInterface $encoder)
241
    {
242 3
        $this->encoder = $encoder;
243
244 3
        return $this;
245
    }
246
247
    /**
248
     * @inheritdoc
249
     */
250 1
    public function getEncoderMediaType()
251
    {
252 1
        return $this->encoderMediaType;
253
    }
254
255
    /**
256
     * Sets response encoder media type
257
     *
258
     * @param MediaTypeInterface $encoderMediaType
259
     * @return $this
260
     */
261 3
    public function setEncoderMediaType(MediaTypeInterface $encoderMediaType)
262
    {
263 3
        $this->encoderMediaType = $encoderMediaType;
264
265 3
        return $this;
266
    }
267
268
    /**
269
     * @inheritdoc
270
     */
271 3
    public function setDecoder(DecoderInterface $decoder)
272
    {
273 3
        $this->decoder = $decoder;
274
275 3
        return $this;
276
    }
277
278
    /**
279
     * @inheritdoc
280
     */
281 1
    public function getDecoder()
282
    {
283 1
        return $this->decoder;
284
    }
285
286
    /**
287
     * Sets environment configuration from array
288
     *
289
     * @param array $config
290
     */
291 1
    protected function fromArray(array $config)
292
    {
293
        $fields = [
294 1
            'query' => 'setQueryType',
295
            'body' => 'setBodyType',
296
            'matcher' => 'setMatcherConfiguration',
297
            'urlPrefix' => 'setUrlPrefix',
298
            'serialization' => 'setSerializationGroups',
299
            'validation' => 'setValidationGroups'
300
        ];
301
302 1
        foreach ($fields as $field => $setter) {
303 1
            if (!array_key_exists($field, $config)) {
304 1
                continue;
305
            }
306
307 1
            $this->{$setter}($config[$field]);
308
        }
309 1
    }
310
}
311