PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.1
3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 3.0.0 3.0.1 All 71 releases
stockpack / vendor / guzzlehttp / guzzle / src / TransferStats.php

TransferStats.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.1, at vendor/guzzlehttp/guzzle/src/TransferStats.php

127 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp;
3
4 use Psr\Http\Message\RequestInterface;
5 use Psr\Http\Message\ResponseInterface;
6 use Psr\Http\Message\UriInterface;
7
8 /**
9 * Represents data at the point after it was transferred either successfully
10 * or after a network error.
11 */
12 final class TransferStats
13 {
14 private $request;
15 private $response;
16 private $transferTime;
17 private $handlerStats;
18 private $handlerErrorData;
19
20 /**
21 * @param RequestInterface $request Request that was sent.
22 * @param ResponseInterface|null $response Response received (if any)
23 * @param float|null $transferTime Total handler transfer time.
24 * @param mixed $handlerErrorData Handler error data.
25 * @param array $handlerStats Handler specific stats.
26 */
27 public function __construct(
28 RequestInterface $request,
29 ResponseInterface $response = null,
30 $transferTime = null,
31 $handlerErrorData = null,
32 $handlerStats = []
33 ) {
34 $this->request = $request;
35 $this->response = $response;
36 $this->transferTime = $transferTime;
37 $this->handlerErrorData = $handlerErrorData;
38 $this->handlerStats = $handlerStats;
39 }
40
41 /**
42 * @return RequestInterface
43 */
44 public function getRequest()
45 {
46 return $this->request;
47 }
48
49 /**
50 * Returns the response that was received (if any).
51 *
52 * @return ResponseInterface|null
53 */
54 public function getResponse()
55 {
56 return $this->response;
57 }
58
59 /**
60 * Returns true if a response was received.
61 *
62 * @return bool
63 */
64 public function hasResponse()
65 {
66 return $this->response !== null;
67 }
68
69 /**
70 * Gets handler specific error data.
71 *
72 * This might be an exception, a integer representing an error code, or
73 * anything else. Relying on this value assumes that you know what handler
74 * you are using.
75 *
76 * @return mixed
77 */
78 public function getHandlerErrorData()
79 {
80 return $this->handlerErrorData;
81 }
82
83 /**
84 * Get the effective URI the request was sent to.
85 *
86 * @return UriInterface
87 */
88 public function getEffectiveUri()
89 {
90 return $this->request->getUri();
91 }
92
93 /**
94 * Get the estimated time the request was being transferred by the handler.
95 *
96 * @return float|null Time in seconds.
97 */
98 public function getTransferTime()
99 {
100 return $this->transferTime;
101 }
102
103 /**
104 * Gets an array of all of the handler specific transfer data.
105 *
106 * @return array
107 */
108 public function getHandlerStats()
109 {
110 return $this->handlerStats;
111 }
112
113 /**
114 * Get a specific handler statistic from the handler by name.
115 *
116 * @param string $stat Handler specific transfer stat to retrieve.
117 *
118 * @return mixed|null
119 */
120 public function getHandlerStat($stat)
121 {
122 return isset($this->handlerStats[$stat])
123 ? $this->handlerStats[$stat]
124 : null;
125 }
126 }
127