Conditions | 5 |
Paths | 12 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5.0061 |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
19 | 2 | public function formatRequest(RequestInterface $request) |
|
20 | { |
||
21 | 2 | $command = sprintf('curl \'%s\'', $request->getUri()); |
|
22 | 2 | if ($request->getProtocolVersion() === '1.0') { |
|
23 | $command .= ' --http1.0'; |
||
24 | 2 | } elseif ($request->getProtocolVersion() === '2.0') { |
|
25 | 1 | $command .= ' --http2'; |
|
26 | 1 | } |
|
27 | |||
28 | 2 | $command .= ' --request '.$request->getMethod(); |
|
29 | |||
30 | 2 | foreach ($request->getHeaders() as $name => $values) { |
|
31 | 1 | $command .= sprintf(' -H \'%s: %s\'', $name, $request->getHeaderLine($name)); |
|
32 | 2 | } |
|
33 | |||
34 | 2 | $body = $request->getBody()->__toString(); |
|
35 | 2 | if (!empty($body)) { |
|
36 | 1 | $command .= sprintf(' --data \'%s\'', $body); |
|
37 | 1 | } |
|
38 | |||
39 | 2 | return $command; |
|
40 | } |
||
41 | |||
50 |