Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 13 |
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 | default: |
||
23 | throw new \Exception("Method not recognised"); |
||
24 | } |
||
25 | |||
26 | if ($this->isAuthenticated()) { |
||
27 | $request->addHeader("Authorization", "Bearer " . $this->token->getValue()); |
||
28 | } |
||
29 | |||
30 | return $request; |
||
31 | } |
||
32 | |||
51 | } |