RequestErroredEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 63
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getException() 0 4 1
A setException() 0 4 1
A hasResponse() 0 4 1
A getResponse() 0 4 1
A setResponse() 0 4 1
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