| @@ 22-125 (lines=104) @@ | ||
| 19 | /** |
|
| 20 | * @author GeLo <[email protected]> |
|
| 21 | */ |
|
| 22 | class RequestCreatedEvent extends AbstractEvent |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var InternalRequestInterface |
|
| 26 | */ |
|
| 27 | private $request; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var ResponseInterface|null |
|
| 31 | */ |
|
| 32 | private $response; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @var HttpAdapterException|null |
|
| 36 | */ |
|
| 37 | private $exception; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param HttpAdapterInterface $httpAdapter |
|
| 41 | * @param InternalRequestInterface $request |
|
| 42 | */ |
|
| 43 | public function __construct(HttpAdapterInterface $httpAdapter, InternalRequestInterface $request) |
|
| 44 | { |
|
| 45 | parent::__construct($httpAdapter); |
|
| 46 | ||
| 47 | $this->setRequest($request); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @return InternalRequestInterface |
|
| 52 | */ |
|
| 53 | public function getRequest() |
|
| 54 | { |
|
| 55 | return $this->request; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param InternalRequestInterface $request |
|
| 60 | */ |
|
| 61 | public function setRequest(InternalRequestInterface $request) |
|
| 62 | { |
|
| 63 | $this->request = $request; |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * @return bool |
|
| 68 | */ |
|
| 69 | public function hasResponse() |
|
| 70 | { |
|
| 71 | return $this->response !== null; |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * @return ResponseInterface|null |
|
| 76 | */ |
|
| 77 | public function getResponse() |
|
| 78 | { |
|
| 79 | return $this->response; |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * @param ResponseInterface|null $response |
|
| 84 | */ |
|
| 85 | public function setResponse(ResponseInterface $response = null) |
|
| 86 | { |
|
| 87 | $this->response = $response; |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * @return bool |
|
| 92 | */ |
|
| 93 | public function hasException() |
|
| 94 | { |
|
| 95 | return $this->exception !== null; |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * @return HttpAdapterException|null |
|
| 100 | */ |
|
| 101 | public function getException() |
|
| 102 | { |
|
| 103 | return $this->exception; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * @param HttpAdapterException|null $exception |
|
| 108 | */ |
|
| 109 | public function setException(HttpAdapterException $exception = null) |
|
| 110 | { |
|
| 111 | $this->exception = $exception; |
|
| 112 | } |
|
| 113 | } |
|
| 114 | ||
| @@ 22-120 (lines=99) @@ | ||
| 19 | /** |
|
| 20 | * @author GeLo <[email protected]> |
|
| 21 | */ |
|
| 22 | class RequestSentEvent extends AbstractEvent |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var InternalRequestInterface |
|
| 26 | */ |
|
| 27 | private $request; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var ResponseInterface|null |
|
| 31 | */ |
|
| 32 | private $response; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @var HttpAdapterException|null |
|
| 36 | */ |
|
| 37 | private $exception; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param HttpAdapterInterface $httpAdapter |
|
| 41 | * @param InternalRequestInterface $request |
|
| 42 | * @param ResponseInterface $response |
|
| 43 | */ |
|
| 44 | public function __construct( |
|
| 45 | HttpAdapterInterface $httpAdapter, |
|
| 46 | InternalRequestInterface $request, |
|
| 47 | ResponseInterface $response |
|
| 48 | ) { |
|
| 49 | parent::__construct($httpAdapter); |
|
| 50 | ||
| 51 | $this->setRequest($request); |
|
| 52 | $this->setResponse($response); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @return InternalRequestInterface |
|
| 57 | */ |
|
| 58 | public function getRequest() |
|
| 59 | { |
|
| 60 | return $this->request; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @param InternalRequestInterface $request |
|
| 65 | */ |
|
| 66 | public function setRequest(InternalRequestInterface $request) |
|
| 67 | { |
|
| 68 | $this->request = $request; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return ResponseInterface|null |
|
| 73 | */ |
|
| 74 | public function getResponse() |
|
| 75 | { |
|
| 76 | return $this->response; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @param ResponseInterface|null $response |
|
| 81 | */ |
|
| 82 | public function setResponse(ResponseInterface $response = null) |
|
| 83 | { |
|
| 84 | $this->response = $response; |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * @return bool |
|
| 89 | */ |
|
| 90 | public function hasException() |
|
| 91 | { |
|
| 92 | return $this->exception !== null; |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * @return HttpAdapterException|null |
|
| 97 | */ |
|
| 98 | public function getException() |
|
| 99 | { |
|
| 100 | return $this->exception; |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * @param HttpAdapterException|null $exception |
|
| 105 | */ |
|
| 106 | public function setException(HttpAdapterException $exception = null) |
|
| 107 | { |
|
| 108 | $this->exception = $exception; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||