FilterResponseEvent::setResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the jade/jade package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jade\HttpKernel\Event;
13
14
use Psr\Http\Message\ResponseInterface;
15
use Psr\Http\Message\ServerRequestInterface;
16
use Jade\HttpKernel\HttpKernel;
17
18
/**
19
 * 允许动态修改内核周期结束之后产生的response
20
 */
21
class FilterResponseEvent extends KernelEvent
22
{
23
    protected $response;
24
25
    public function __construct(HttpKernel $kernel, ServerRequestInterface $request, ResponseInterface $response)
26
    {
27
        parent::__construct($kernel, $request);
28
        $this->response = $response;
29
    }
30
31
    /**
32
     * 返回当前处理得到的response
33
     *
34
     * @return ResponseInterface
35
     */
36
    public function getResponse()
37
    {
38
        return $this->response;
39
    }
40
41
    /**
42
     * 设置一个新的response对象来替换
43
     *
44
     * @param ResponseInterface $response
45
     */
46
    public function setResponse(ResponseInterface $response)
47
    {
48
        $this->response = $response;
49
    }
50
}