|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Ivory Http Adapter package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Ivory\HttpAdapter\Event; |
|
13
|
|
|
|
|
14
|
|
|
use Ivory\HttpAdapter\HttpAdapterException; |
|
15
|
|
|
use Ivory\HttpAdapter\HttpAdapterInterface; |
|
16
|
|
|
use Ivory\HttpAdapter\Message\ResponseInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author GeLo <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class RequestErroredEvent extends AbstractEvent |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var HttpAdapterException |
|
25
|
|
|
*/ |
|
26
|
|
|
private $exception; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var ResponseInterface|null |
|
30
|
|
|
*/ |
|
31
|
|
|
private $response; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param HttpAdapterInterface $httpAdapter |
|
35
|
|
|
* @param HttpAdapterException $exception |
|
36
|
|
|
*/ |
|
37
|
126 |
|
public function __construct(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception) |
|
38
|
|
|
{ |
|
39
|
126 |
|
parent::__construct($httpAdapter); |
|
40
|
|
|
|
|
41
|
126 |
|
$this->setException($exception); |
|
42
|
126 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return HttpAdapterException |
|
46
|
|
|
*/ |
|
47
|
117 |
|
public function getException() |
|
48
|
|
|
{ |
|
49
|
117 |
|
return $this->exception; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param HttpAdapterException $exception |
|
54
|
|
|
*/ |
|
55
|
126 |
|
public function setException(HttpAdapterException $exception) |
|
56
|
|
|
{ |
|
57
|
126 |
|
$this->exception = $exception; |
|
58
|
126 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return bool |
|
62
|
|
|
*/ |
|
63
|
63 |
|
public function hasResponse() |
|
64
|
|
|
{ |
|
65
|
63 |
|
return $this->response !== null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return ResponseInterface|null |
|
70
|
|
|
*/ |
|
71
|
36 |
|
public function getResponse() |
|
72
|
|
|
{ |
|
73
|
36 |
|
return $this->response; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param ResponseInterface $response |
|
78
|
|
|
*/ |
|
79
|
27 |
|
public function setResponse(ResponseInterface $response) |
|
80
|
|
|
{ |
|
81
|
27 |
|
$this->response = $response; |
|
82
|
27 |
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|