Completed
Push — master ( 09c050...8664f4 )
by Eric
10s
created

ResponseEvent::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Jarvis\Skill\EventBroadcaster;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
/**
11
 * @author Eric Chau <[email protected]>
12
 */
13
class ResponseEvent extends SimpleEvent
14
{
15
    protected $request;
16
    protected $response;
17
18
    public function __construct(Request $request, $response)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
19
    {
20
        $this->request = $request;
21
        if (!($response instanceof Response)) {
22
            $response = new Response($response);
23
        }
24
25
        $this->response = $response;
26
    }
27
28
    /**
29
     * @codeCoverageIgnore
30
     *
31
     * @return Request
32
     */
33
    public function request(): Request
34
    {
35
        return $this->request;
36
    }
37
38
    /**
39
     * @codeCoverageIgnore
40
     *
41
     * @return Response
42
     */
43
    public function response()
44
    {
45
        return $this->response;
46
    }
47
}
48