| 1 |
<?php |
| 2 |
|
| 3 |
namespace GuzzleHttp; |
| 4 |
|
| 5 |
use Psr\Http\Message\RequestInterface; |
| 6 |
use Psr\Http\Message\ResponseInterface; |
| 7 |
use Psr\Http\Message\UriInterface; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
final class TransferStats |
| 14 |
{ |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
private $request; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
private $response; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
private $transferTime; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
private $handlerStats; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
private $handlerErrorData; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public function __construct( |
| 48 |
RequestInterface $request, |
| 49 |
?ResponseInterface $response = null, |
| 50 |
?float $transferTime = null, |
| 51 |
$handlerErrorData = null, |
| 52 |
array $handlerStats = [] |
| 53 |
) { |
| 54 |
$this->request = $request; |
| 55 |
$this->response = $response; |
| 56 |
$this->transferTime = $transferTime; |
| 57 |
$this->handlerErrorData = $handlerErrorData; |
| 58 |
$this->handlerStats = $handlerStats; |
| 59 |
} |
| 60 |
|
| 61 |
public function getRequest(): RequestInterface |
| 62 |
{ |
| 63 |
return $this->request; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function getResponse(): ?ResponseInterface |
| 70 |
{ |
| 71 |
return $this->response; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public function hasResponse(): bool |
| 78 |
{ |
| 79 |
return $this->response !== null; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
public function getHandlerErrorData() |
| 92 |
{ |
| 93 |
return $this->handlerErrorData; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
public function getEffectiveUri(): UriInterface |
| 100 |
{ |
| 101 |
return $this->request->getUri(); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
public function getTransferTime(): ?float |
| 110 |
{ |
| 111 |
return $this->transferTime; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public function getHandlerStats(): array |
| 118 |
{ |
| 119 |
return $this->handlerStats; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public function getHandlerStat(string $stat) |
| 130 |
{ |
| 131 |
return $this->handlerStats[$stat] ?? null; |
| 132 |
} |
| 133 |
} |