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 ( 134146...83d859 )
by Niels
11:03
created

Request::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php namespace Ntholenaar\MultiSafepayClient\Request;
2
3
use Http\Discovery\MessageFactoryDiscovery;
4
use Http\Discovery\UriFactoryDiscovery;
5
use Http\Message\MessageFactory;
6
use Http\Message\UriFactory;
7
use Psr\Http\Message\UriInterface;
8
9
class Request implements RequestInterface
10
{
11
    /**
12
     * @var MessageFactory
13
     */
14
    protected $messageFactory;
15
16
    /**
17
     * @var UriFactory
18
     */
19
    protected $uriFactory;
20
21
    /**
22
     * @var string
23
     */
24
    protected $baseUrl = '';
25
26
    /**
27
     * @param MessageFactory|null $messageFactory
28
     * @param UriFactory|null $uriFactory
29
     */
30
    public function __construct(MessageFactory $messageFactory = null, UriFactory $uriFactory = null)
31
    {
32
        if (is_null($messageFactory)) {
33
            $messageFactory = MessageFactoryDiscovery::find();
34
        }
35
36
        if (is_null($uriFactory)) {
37
            $uriFactory = UriFactoryDiscovery::find();
38
        }
39
40
        $this->setUriFactory($uriFactory);
41
42
        $this->setMessageFactory($messageFactory);
43
    }
44
45
    /**
46
     * Get the MessageFactory.
47
     *
48
     * @return MessageFactory
49
     */
50
    protected function getMessageFactory()
51
    {
52
        return $this->messageFactory;
53
    }
54
55
    /**
56
     * Set the MessageFactory.
57
     *
58
     * @param MessageFactory $messageFactory
59
     * @return $this
60
     */
61
    protected function setMessageFactory(MessageFactory $messageFactory)
62
    {
63
        $this->messageFactory = $messageFactory;
64
65
        return $this;
66
    }
67
68
    /**
69
     * Get the UriFactory.
70
     *
71
     * @return UriFactory
72
     */
73
    protected function getUriFactory()
74
    {
75
        return $this->uriFactory;
76
    }
77
78
    /**
79
     * Set the UriFactory.
80
     *
81
     * @param UriFactory $uriFactory
82
     * @return $this
83
     */
84
    protected function setUriFactory(UriFactory $uriFactory)
85
    {
86
        $this->uriFactory = $uriFactory;
87
88
        return $this;
89
    }
90
91
    /**
92
     * Get the base url.
93
     *
94
     * @return string
95
     */
96
    protected function getBaseUrl()
97
    {
98
        return $this->baseUrl;
99
    }
100
101
    /**
102
     * Set the base url.
103
     *
104
     * @param $baseUrl
105
     * @return $this
106
     */
107
    protected function setBaseUrl($baseUrl)
108
    {
109
        $this->baseUrl = $baseUrl;
110
111
        return $this;
112
    }
113
114
    /**
115
     * Create GET request.
116
     *
117
     *
118
     * @param UriInterface $uri
119
     * @param array $query
120
     * @return \Psr\Http\Message\RequestInterface
121
     */
122
    protected function get(UriInterface $uri, array $query = array())
123
    {
124
        $uri = $uri->withQuery(http_build_query($query));
125
126
        return $this->messageFactory->createRequest('GET', $uri);
127
    }
128
129
    /**
130
     * Create POST request.
131
     *
132
     * @param UriInterface $uri
133
     * @param array $query
134
     * @param array $body
135
     * @return \Psr\Http\Message\RequestInterface
136
     */
137
    protected function post(UriInterface $uri, array $query = array(), array $body = array())
138
    {
139
        $uri = $uri->withQuery(http_build_query($query));
140
141
        $body = json_encode($body);
142
143
        return $this->messageFactory->createRequest('POST', $uri, array(), $body);
144
    }
145
}
146