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 ( 8fc84e...73459b )
by François
01:58
created

Request::getHeader()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
/**
4
 * Copyright (c) 2016, 2017 François Kooman <[email protected]>.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
25
namespace fkooman\OAuth\Client\Http;
26
27
class Request
28
{
29
    /** @var string */
30
    private $requestMethod;
31
32
    /** @var string */
33
    private $requestUri;
34
35
    /** @var string|null */
36
    private $requestBody;
37
38
    /** @var array */
39
    private $requestHeaders;
40
41
    /**
42
     * @param string $requestMethod
43
     * @param string $requestUri
44
     * @param array  $requestHeaders
45
     * @param string $requestBody
46
     */
47
    public function __construct($requestMethod, $requestUri, array $requestHeaders = [], $requestBody = null)
48
    {
49
        $this->requestMethod = $requestMethod;
50
        $this->requestUri = $requestUri;
51
        $this->requestBody = $requestBody;
52
        $this->requestHeaders = $requestHeaders;
53
    }
54
55
    public function __toString()
56
    {
57
        $fmtHdrs = '';
58
        foreach ($this->requestHeaders as $k => $v) {
59
            $fmtHdrs .= sprintf('%s: %s', $k, $v).PHP_EOL;
60
        }
61
62
        return implode(
63
            PHP_EOL,
64
            [
65
                $this->requestUri,
66
                $this->requestMethod,
67
                $fmtHdrs,
68
                '',
69
                $this->requestBody,
70
            ]
71
        );
72
    }
73
74
    /**
75
     * @param string $requestUri
76
     * @param array  $requestHeaders
77
     */
78
    public static function get($requestUri, array $requestHeaders = [])
79
    {
80
        return new self('GET', $requestUri, $requestHeaders);
81
    }
82
83
    /**
84
     * @param string $requestUri
85
     * @param array  $postData
86
     * @param array  $requestHeaders
87
     */
88
    public static function post($requestUri, array $postData = [], array $requestHeaders = [])
89
    {
90
        return new self(
91
            'POST',
92
            $requestUri,
93
            array_merge(
94
                $requestHeaders,
95
                ['Content-Type' => 'application/x-www-form-urlencoded']
96
            ),
97
            http_build_query($postData, '&')
98
        );
99
    }
100
101
    /**
102
     * @param string $key
103
     * @param string $value
104
     */
105
    public function setHeader($key, $value)
106
    {
107
        $this->requestHeaders[$key] = $value;
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    public function getMethod()
114
    {
115
        return $this->requestMethod;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function getUri()
122
    {
123
        return $this->requestUri;
124
    }
125
126
    /**
127
     * @return string|null
128
     */
129
    public function getBody()
130
    {
131
        return $this->requestBody;
132
    }
133
134
    /**
135
     * @return array
136
     */
137
    public function getHeaders()
138
    {
139
        return $this->requestHeaders;
140
    }
141
}
142