Passed
Push — master ( acba12...b2f89b )
by 世昌
04:15
created

RequestDumper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dumpThrowable() 0 6 2
A __construct() 0 7 1
1
<?php
2
namespace suda\application\debug;
3
4
use Exception;
5
use Throwable;
6
use suda\framework\Request;
7
use suda\framework\Response;
8
use suda\application\Application;
9
use suda\framework\debug\DebugObject;
10
use suda\framework\filesystem\FileSystem;
11
12
/**
13
 * Class RequestDumper
14
 * @package suda\application
15
 */
16
class RequestDumper extends ExceptionCatcher
17
{
18
    /**
19
     * @var Response
20
     */
21
    protected $response;
22
23
24
    public function __construct(Application $application, Request $request, Response $response)
25
    {
26
        $context = [];
27
        $context['request'] = $request;
28
        $context['response'] = $response;
29
        parent::__construct($application, $context);
30
        $this->response = $response;
31
    }
32
33
    /**
34
     * @param Throwable $throwable
35
     */
36
    public function dumpThrowable($throwable)
37
    {
38
        parent::dumpThrowable($throwable);
39
        if ($this->response->isSend() === false) {
40
            $this->response->sendContent($throwable);
41
            $this->response->end();
42
        }
43
    }
44
}
45