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