PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / GuzzleHttp / TransferStats.php

TransferStats.php in Media Cloud Sync 1.4.1, at includes/sdk/s3/GuzzleHttp/TransferStats.php

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