| Conditions | 5 |
| Paths | 7 |
| Total Lines | 25 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function prepare(HttpMethod $method, string $url, string $body = ""): Request |
||
| 14 | { |
||
| 15 | switch ($method) { |
||
| 16 | case HttpMethod::POST(): |
||
| 17 | $request = $this->post($url, $body); |
||
| 18 | break; |
||
| 19 | case HttpMethod::GET(): |
||
| 20 | $request = $this->get($url); |
||
| 21 | break; |
||
| 22 | case HttpMethod::PUT(): |
||
| 23 | $request = $this->put($url, $body); |
||
| 24 | break; |
||
| 25 | default: |
||
| 26 | throw new \Exception("Method not recognised"); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($this->isAuthenticated()) { |
||
| 30 | $request->addHeader("Authorization", "Bearer " . $this->token->getValue()); |
||
| 31 | } |
||
| 32 | |||
| 33 | $request->sends('application/json'); |
||
| 34 | $request->expects('application/json'); |
||
| 35 | |||
| 36 | return $request; |
||
| 37 | } |
||
| 38 | |||
| 67 | } |