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::parseMetadataHeaders()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4286
cc 3
eloc 6
nc 3
nop 2
crap 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A RequestSerializer::stockMetadataHeader() 0 7 3
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
}