Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 1 | public function convert(RequestInterface $request, TokenInterface $token, $uri) |
|
18 | { |
||
19 | $opts = array( |
||
20 | 'http' => array( |
||
21 | 1 | 'method' => $request->getMethod(), |
|
22 | 'header' => array( |
||
23 | 1 | 'Content-type: application/json', |
|
24 | 1 | ), |
|
25 | 1 | ), |
|
26 | 1 | ); |
|
27 | |||
28 | 1 | $auth = $token->getAuthentication(); |
|
29 | 1 | $auth = $auth[0] . ':' . $auth[1]; |
|
30 | 1 | $auth = base64_encode($auth); |
|
31 | 1 | $opts['http']['header'][] = 'Authorization: Basic ' . $auth; |
|
32 | |||
33 | 1 | if (!empty($request->getData())) { |
|
34 | 1 | $opts['http']['content'] = json_encode($request); |
|
35 | 1 | } |
|
36 | |||
37 | 1 | $uri = $uri . '/' . $request->getUri(); |
|
38 | |||
39 | return array( |
||
40 | 1 | 'uri' => $uri, |
|
41 | 1 | 'options' => $opts, |
|
42 | 1 | ); |
|
43 | } |
||
44 | } |
||
45 |