Completed
Pull Request — master (#129)
by Eric
257:01 queued 192:06
created

src/Event/RequestCreatedEvent.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 created event.
21
 *
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class RequestCreatedEvent 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 created event.
37
     *
38
     * @param \Ivory\HttpAdapter\HttpAdapterInterface             $httpAdapter The http adapter.
39
     * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $request     The request.
40
     */
41 380
    public function __construct(HttpAdapterInterface $httpAdapter, InternalRequestInterface $request)
42
    {
43 380
        parent::__construct($httpAdapter);
44
45 380
        $this->setRequest($request);
46 380
    }
47
48
    /**
49
     * Gets the request.
50
     *
51
     * @return \Ivory\HttpAdapter\Message\InternalRequestInterface The request.
52
     */
53 342
    public function getRequest()
54
    {
55 342
        return $this->request;
56
    }
57
58
    /**
59
     * Sets the request.
60
     *
61
     * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $request The request.
62
     */
63 380
    public function setRequest(InternalRequestInterface $request)
64
    {
65 380
        $this->request = $request;
66 380
    }
67
68
    /**
69
     * Checks if there is a response.
70
     *
71
     * @return boolean TRUE if there is a response else FALSE.
72
     */
73 152
    public function hasResponse()
74
    {
75 152
        return $this->response !== null;
76
    }
77
78
    /**
79
     * Gets the response.
80
     *
81
     * @return \Ivory\HttpAdapter\Message\ResponseInterface|null
82
     */
83 114
    public function getResponse()
84
    {
85 114
        return $this->response;
86
    }
87
88
    /**
89
     * Sets the response.
90
     *
91
     * @param \Ivory\HttpAdapter\Message\ResponseInterface|null $response
92
     */
93 57
    public function setResponse(ResponseInterface $response = null)
94
    {
95 57
        $this->response = $response;
96 57
    }
97
98
    /**
99
     * Checks if there is an exception.
100
     *
101
     * @return boolean TRUE if there is an exception else FALSE.
102
     */
103 171
    public function hasException()
104
    {
105 171
        return $this->exception !== null;
106
    }
107
108
    /**
109
     * Gets the exception.
110
     *
111
     * @return \Ivory\HttpAdapter\HttpAdapterException|null
112
     */
113 114
    public function getException()
114
    {
115 114
        return $this->exception;
116
    }
117
118
    /**
119
     * Sets the exception.
120
     *
121
     * @param \Ivory\HttpAdapter\HttpAdapterException|null $exception
122
     */
123 57
    public function setException(HttpAdapterException $exception = null)
124
    {
125 57
        $this->exception = $exception;
126 57
    }
127
}
128