1<?php 2namespace GuzzleHttp; 3 4use GuzzleHttp\Message\RequestInterface; 5use GuzzleHttp\Message\ResponseInterface; 6 7/** 8 * Represents the relationship between a client, request, and response. 9 * 10 * You can access the request, response, and client using their corresponding 11 * public properties. 12 */ 13class Transaction 14{ 15 /** 16 * HTTP client used to transfer the request. 17 * 18 * @var ClientInterface 19 */ 20 public $client; 21 22 /** 23 * The request that is being sent. 24 * 25 * @var RequestInterface 26 */ 27 public $request; 28 29 /** 30 * The response associated with the transaction. A response will not be 31 * present when a networking error occurs or an error occurs before sending 32 * the request. 33 * 34 * @var ResponseInterface|null 35 */ 36 public $response; 37 38 /** 39 * Exception associated with the transaction. If this exception is present 40 * when processing synchronous or future commands, then it is thrown. When 41 * intercepting a failed transaction, you MUST set this value to null in 42 * order to prevent the exception from being thrown. 43 * 44 * @var \Exception 45 */ 46 public $exception; 47 48 /** 49 * Associative array of handler specific transfer statistics and custom 50 * key value pair information. When providing similar information, handlers 51 * should follow the same key value pair naming conventions as PHP's 52 * curl_getinfo() (http://php.net/manual/en/function.curl-getinfo.php). 53 * 54 * @var array 55 */ 56 public $transferInfo = []; 57 58 /** 59 * The number of transaction retries. 60 * 61 * @var int 62 */ 63 public $retries = 0; 64 65 /** 66 * The transaction's current state. 67 * 68 * @var string 69 */ 70 public $state; 71 72 /** 73 * Whether or not this is a future transaction. This value should not be 74 * changed after the future is constructed. 75 * 76 * @var bool 77 */ 78 public $future; 79 80 /** 81 * The number of state transitions that this transaction has been through. 82 * 83 * @var int 84 * @internal This is for internal use only. If you modify this, then you 85 * are asking for trouble. 86 */ 87 public $_transitionCount = 0; 88 89 /** 90 * @param ClientInterface $client Client that is used to send the requests 91 * @param RequestInterface $request Request to send 92 * @param bool $future Whether or not this is a future request. 93 */ 94 public function __construct( 95 ClientInterface $client, 96 RequestInterface $request, 97 $future = false 98 ) { 99 $this->client = $client; 100 $this->request = $request; 101 $this->_future = $future; 102 } 103} 104