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.
Passed
Push — master ( 658651...354c7c )
by Jamie
07:31
created

RequestSerializer::stockOptions()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
ccs 17
cts 17
cp 1
rs 8.8571
cc 6
eloc 15
nc 6
nop 4
crap 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A RequestSerializer::stockUrl() 0 2 1
A RequestSerializer::stockQuery() 0 4 1
1
<?php
2
3
namespace OpenStack\Common\Transport;
4
5
use function GuzzleHttp\uri_template;
6
use function GuzzleHttp\Psr7\build_query;
7
use function GuzzleHttp\Psr7\modify_request;
8
9
use OpenStack\Common\Api\Operation;
10
use OpenStack\Common\Api\Parameter;
11
12
class RequestSerializer
13
{
14
    private $jsonSerializer;
15
16 182
    public function __construct(JsonSerializer $jsonSerializer = null)
17
    {
18 182
        $this->jsonSerializer = $jsonSerializer ?: new JsonSerializer();
19 182
    }
20
21 182
    public function serializeOptions(Operation $operation, array $userValues = [])
22
    {
23 182
        $options = ['headers' => []];
24
25 182
        foreach ($userValues as $paramName => $paramValue) {
26 168
            if (null === ($schema = $operation->getParam($paramName))) {
27 1
                continue;
28
            }
29
30 167
            $method = sprintf('stock%s', ucfirst($schema->getLocation()));
31 167
            $this->$method($schema, $paramValue, $options);
32 182
        }
33
34 182
        if (!empty($options['json']) && ($key = $operation->getJsonKey())) {
35 36
            $options['json'] = [$key => $options['json']];
36 36
        }
37
38 182
        return $options;
39
    }
40
41 115
    private function stockUrl()
42 115
    {}
43
44 11
    private function stockQuery(Parameter $schema, $paramValue, array &$options)
45
    {
46 11
        $options['query'][$schema->getName()] = $paramValue;
47 11
    }
48
49 15
    private function stockHeader(Parameter $schema, $paramValue, array &$options)
50
    {
51 15
        $paramName = $schema->getName();
52
53 15
        if (strpos(strtolower($paramName), 'metadata') !== false) {
54 9
            return $this->stockMetadataHeader($schema, $paramValue, $options);
55
        }
56
57 15
        $options['headers'] += is_scalar($paramValue) ? [$schema->getPrefixedName() => $paramValue] : [];
58 15
    }
59
60 9
    private function stockMetadataHeader(Parameter $schema, $paramValue, array &$options)
61
    {
62 9
        foreach ($paramValue as $key => $keyVal) {
63 9
            $schema = $schema->getItemSchema() ?: new Parameter(['prefix' => $schema->getPrefix(), 'name' => $key]);
64 9
            $this->stockHeader($schema, $keyVal, $options);
65 9
        }
66 9
    }
67
68 62
    private function stockJson(Parameter $schema, $paramValue, array &$options)
69
    {
70 62
        $json = isset($options['json']) ? $options['json'] : [];
71 62
        $options['json'] = $this->jsonSerializer->stockJson($schema, $paramValue, $json);
72 62
    }
73
74 3
    private function stockRaw(Parameter $schema, $paramValue, array &$options)
0 ignored issues
show
Unused Code introduced by
The parameter $schema is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76 3
        $options['body'] = $paramValue;
77
    }
78
}