Namshi\Cuzzle\Formatter\CurlFormatter::format PHP Method

format() public method

public format ( Psr\Http\Message\RequestInterface $request, array $options = [] ) : string
$request Psr\Http\Message\RequestInterface
$options array
return string
    public function format(RequestInterface $request, array $options = [])
    {
        $this->command = 'curl';
        $this->currentLineLength = strlen($this->command);
        $this->options = [];
        $this->extractArguments($request, $options);
        $this->addOptionsToCommand();
        return $this->command;
    }

Usage Example

示例#1
0
 public function testProperBodyReading()
 {
     $request = new Request('PUT', 'example.local', [], Stream::factory('foo=bar&hello=world'));
     $request->getBody()->getContents();
     $curl = $this->curlFormatter->format($request);
     $this->assertContains("-d 'foo=bar&hello=world'", $curl);
     $this->assertContains("-X PUT", $curl);
 }
All Usage Examples Of Namshi\Cuzzle\Formatter\CurlFormatter::format