コード例 #1
0
 /**
  * SpiralClient constructor.
  *
  * @param Transport|null $transport
  */
 public function __construct(Transport $transport = null)
 {
     if (is_null($transport)) {
         $transport = Transport\Curl::createFromDefaults();
     }
     $this->transport = $transport;
 }
コード例 #2
0
ファイル: Client.php プロジェクト: juliangut/spiral
 /**
  * Retrieve transport handler.
  *
  * @return TransportInterface
  */
 public function getTransport()
 {
     if (!$this->transport instanceof TransportInterface) {
         $this->transport = Curl::createFromDefaults();
     }
     return $this->transport;
 }
コード例 #3
0
ファイル: CurlTest.php プロジェクト: juliangut/spiral
 /**
  * @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();
 }