1 | <?php declare(strict_types=1); |
||
33 | class APIRequestBuilder { |
||
34 | use LoggerAwareTrait; |
||
35 | |||
36 | /** |
||
37 | * Url prefix for making url requests |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $baseUrl = ''; |
||
41 | |||
42 | /** |
||
43 | * Url path of the request |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $path = ''; |
||
47 | |||
48 | /** |
||
49 | * Query string for the request |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $query = ''; |
||
53 | |||
54 | /** |
||
55 | * Default request headers |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $defaultHeaders = []; |
||
59 | |||
60 | /** |
||
61 | * Valid HTTP request methos |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']; |
||
65 | |||
66 | /** |
||
67 | * The current request |
||
68 | * @var \Amp\Promise |
||
69 | */ |
||
70 | protected $request; |
||
71 | |||
72 | /** |
||
73 | * Set an authorization header |
||
74 | * |
||
75 | * @param string $type The type of authorization, eg, basic, bearer, etc. |
||
76 | * @param string $value The authorization value |
||
77 | * @return self |
||
78 | */ |
||
79 | public function setAuth(string $type, string $value): self |
||
86 | |||
87 | /** |
||
88 | * Set a basic authentication header |
||
89 | * |
||
90 | * @param string $username |
||
91 | * @param string $password |
||
92 | * @return self |
||
93 | */ |
||
94 | public function setBasicAuth(string $username, string $password): self |
||
99 | |||
100 | /** |
||
101 | * Set the request body |
||
102 | * |
||
103 | * @param FormBody|string $body |
||
104 | * @return self |
||
105 | */ |
||
106 | public function setBody($body): self |
||
111 | |||
112 | /** |
||
113 | * Set body as form fields |
||
114 | * |
||
115 | * @param array $fields Mapping of field names to values |
||
116 | * @return self |
||
117 | */ |
||
118 | public function setFormFields(array $fields): self |
||
125 | |||
126 | /** |
||
127 | * Set a request header |
||
128 | * |
||
129 | * @param string $name |
||
130 | * @param string $value |
||
131 | * @return self |
||
132 | */ |
||
133 | public function setHeader(string $name, string $value): self |
||
138 | |||
139 | /** |
||
140 | * Set multiple request headers |
||
141 | * |
||
142 | * name => value |
||
143 | * |
||
144 | * @param array $headers |
||
145 | * @return self |
||
146 | */ |
||
147 | public function setHeaders(array $headers): self |
||
156 | |||
157 | /** |
||
158 | * Set the request body |
||
159 | * |
||
160 | * @param mixed $body |
||
161 | * @return self |
||
162 | */ |
||
163 | public function setJsonBody($body): self |
||
171 | |||
172 | /** |
||
173 | * Append a query string in array format |
||
174 | * |
||
175 | * @param array $params |
||
176 | * @return self |
||
177 | */ |
||
178 | public function setQuery(array $params): self |
||
183 | |||
184 | /** |
||
185 | * Return the promise for the current request |
||
186 | * |
||
187 | * @return \Amp\Promise |
||
188 | */ |
||
189 | public function getFullRequest() |
||
204 | |||
205 | /** |
||
206 | * Create a new http request |
||
207 | * |
||
208 | * @param string $type |
||
209 | * @param string $uri |
||
210 | * @return self |
||
211 | */ |
||
212 | public function newRequest(string $type, string $uri): self |
||
234 | |||
235 | /** |
||
236 | * Create the full request url |
||
237 | * |
||
238 | * @return void |
||
239 | */ |
||
240 | private function buildUri() |
||
253 | |||
254 | /** |
||
255 | * Reset the class state for a new request |
||
256 | * |
||
257 | * @return void |
||
258 | */ |
||
259 | private function resetState() |
||
265 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.