/** * SpiralClient constructor. * * @param Transport|null $transport */ public function __construct(Transport $transport = null) { if (is_null($transport)) { $transport = Transport\Curl::createFromDefaults(); } $this->transport = $transport; }
/** * Retrieve transport handler. * * @return TransportInterface */ public function getTransport() { if (!$this->transport instanceof TransportInterface) { $this->transport = Curl::createFromDefaults(); } return $this->transport; }
/** * @param string $method * @param string $shorthand * @param int $expectedCode * * @dataProvider methodPayloadProvider */ public function testRequestWithPayload($method, $shorthand, $expectedCode) { $transport = Curl::createFromDefaults(); $transport->request($method, 'http://www.php.net', [], ['var' => 'value']); static::assertEquals($expectedCode, $transport->responseInfo(CURLINFO_HTTP_CODE)); $transport->{$shorthand}('http://www.php.net', [], ['var' => 'value']); static::assertEquals($expectedCode, $transport->responseInfo(CURLINFO_HTTP_CODE)); $transport->close(); }