Completed
Pull Request — master (#129)
by Eric
257:01 queued 192:06
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 361
    public function __construct(
43
        HttpAdapterInterface $httpAdapter,
44
        InternalRequestInterface $request,
45
        ResponseInterface $response
46
    ) {
47 361
        parent::__construct($httpAdapter);
48
49 361
        $this->setRequest($request);
50 361
        $this->setResponse($response);
51 361
    }
52
53
    /**
54
     * Gets the request.
55
     *
56
     * @return \Ivory\HttpAdapter\Message\InternalRequestInterface The request.
57
     */
58 247
    public function getRequest()
59
    {
60 247
        return $this->request;
61
    }
62
63
    /**
64
     * Sets the request.
65
     *
66
     * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $request The request.
67
     */
68 361
    public function setRequest(InternalRequestInterface $request)
69
    {
70 361
        $this->request = $request;
71 361
    }
72
73
    /**
74
     * Gets the response.
75
     *
76
     * @return \Ivory\HttpAdapter\Message\ResponseInterface|null
77
     */
78 285
    public function getResponse()
79
    {
80 285
        return $this->response;
81
    }
82
83
    /**
84
     * Sets the response.
85
     *
86
     * @param \Ivory\HttpAdapter\Message\ResponseInterface|null $response
87
     */
88 361
    public function setResponse(ResponseInterface $response = null)
89
    {
90 361
        $this->response = $response;
91 361
    }
92
93
    /**
94
     * Checks if there is an exception.
95
     *
96
     * @return boolean TRUE if there is an exception else FALSE.
97
     */
98 190
    public function hasException()
99
    {
100 190
        return $this->exception !== null;
101
    }
102
103
    /**
104
     * Gets the exception.
105
     *
106
     * @return \Ivory\HttpAdapter\HttpAdapterException|null
107
     */
108 114
    public function getException()
109
    {
110 114
        return $this->exception;
111
    }
112
113
    /**
114
     * Sets the exception.
115
     *
116
     * @param \Ivory\HttpAdapter\HttpAdapterException|null $exception
117
     */
118 95
    public function setException(HttpAdapterException $exception = null)
119
    {
120 95
        $this->exception = $exception;
121 95
    }
122
}
123