Completed
Push — travis ( f0ed02...4279e5 )
by Eric
192:27 queued 127:20
created

src/Event/RequestSentEvent.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\InternalRequestInterface;
17
use Ivory\HttpAdapter\Message\ResponseInterface;
18
19
/**
20
 * Request sent event.
21
 *
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class RequestSentEvent extends AbstractEvent
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    /** @var \Ivory\HttpAdapter\Message\InternalRequestInterface */
27
    private $request;
28
29
    /** @var \Ivory\HttpAdapter\Message\ResponseInterface|null */
30
    private $response;
31
32
    /** @var \Ivory\HttpAdapter\HttpAdapterException|null */
33
    private $exception;
34
35
    /**
36
     * Creates a request sent event.
37
     *
38
     * @param \Ivory\HttpAdapter\HttpAdapterInterface             $httpAdapter The http adapter.
39
     * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $request     The request.
40
     * @param \Ivory\HttpAdapter\Message\ResponseInterface        $response    The response.
41
     */
42
    public function __construct(
43
        HttpAdapterInterface $httpAdapter,
44
        InternalRequestInterface $request,
45
        ResponseInterface $response
46
    ) {
47
        parent::__construct($httpAdapter);
48
49
        $this->setRequest($request);
50
        $this->setResponse($response);
51
    }
52
53
    /**
54
     * Gets the request.
55
     *
56
     * @return \Ivory\HttpAdapter\Message\InternalRequestInterface The request.
57
     */
58
    public function getRequest()
59
    {
60
        return $this->request;
61
    }
62
63
    /**
64
     * Sets the request.
65
     *
66
     * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $request The request.
67
     */
68
    public function setRequest(InternalRequestInterface $request)
69
    {
70
        $this->request = $request;
71
    }
72
73
    /**
74
     * Gets the response.
75
     *
76
     * @return \Ivory\HttpAdapter\Message\ResponseInterface|null
77
     */
78
    public function getResponse()
79
    {
80
        return $this->response;
81
    }
82
83
    /**
84
     * Sets the response.
85
     *
86
     * @param \Ivory\HttpAdapter\Message\ResponseInterface|null $response
87
     */
88
    public function setResponse(ResponseInterface $response = null)
89
    {
90
        $this->response = $response;
91
    }
92
93
    /**
94
     * Checks if there is an exception.
95
     *
96
     * @return boolean TRUE if there is an exception else FALSE.
97
     */
98
    public function hasException()
99
    {
100
        return $this->exception !== null;
101
    }
102
103
    /**
104
     * Gets the exception.
105
     *
106
     * @return \Ivory\HttpAdapter\HttpAdapterException|null
107
     */
108
    public function getException()
109
    {
110
        return $this->exception;
111
    }
112
113
    /**
114
     * Sets the exception.
115
     *
116
     * @param \Ivory\HttpAdapter\HttpAdapterException|null $exception
117
     */
118
    public function setException(HttpAdapterException $exception = null)
119
    {
120
        $this->exception = $exception;
121
    }
122
}
123