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

ResponseEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 4
c 4
b 0
f 1
lcom 0
cbo 2
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A request() 0 4 1
A response() 0 4 1
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