Total Complexity | 4 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class JsonTransporter implements TransporterInterface |
||
10 | { |
||
11 | /** |
||
12 | * Function to set the appropriate headers on a request object |
||
13 | * to facilitate a JSON transport. |
||
14 | * |
||
15 | * @param Request $request |
||
16 | */ |
||
17 | 37 | public function setHeaderOnRequest(Request $request) |
|
18 | { |
||
19 | 37 | $request->setHeaders([ |
|
20 | 37 | 'Accept' => 'application/json', |
|
21 | 'Content-Type' => 'application/json', |
||
22 | ]); |
||
23 | 37 | } |
|
24 | |||
25 | /** |
||
26 | * Function to convert a response object into an associative |
||
27 | * array of data. |
||
28 | * |
||
29 | * @param Response $response |
||
30 | * |
||
31 | * @return array |
||
32 | * |
||
33 | * @throws \Guzzle\Common\Exception\RuntimeException |
||
34 | */ |
||
35 | 12 | public function parseResponseToData(Response $response) |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Function to parse the response string into an object |
||
42 | * specific to JSON. |
||
43 | * |
||
44 | * @param Response $response |
||
45 | * |
||
46 | * @return mixed |
||
47 | */ |
||
48 | 8 | public function parseResponseStringToObject(Response $response) |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * Set the request body for the given request. |
||
55 | * |
||
56 | * @param RestRequest $request |
||
57 | * @param $body |
||
58 | */ |
||
59 | 6 | public function setRequestBody(RestRequest $request, $body) |
|
64 |