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