Http   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 15
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 106
ccs 34
cts 34
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getStatusCode() 0 8 2
A getStatusText() 0 8 2
A getCharset() 0 8 2
A getMaxAge() 0 8 2
A getExpires() 0 8 2
A getLastModified() 0 8 2
A getTtl() 0 8 2
1
<?php
2
3
namespace Ndrx\Profiler\Collectors\Data\Responses;
4
5
use Ndrx\Profiler\Collectors\Data\Response;
6
use Ndrx\Profiler\DataSources\Contracts\DataSourceInterface;
7
use Ndrx\Profiler\Events\HttpFoundationResponse;
8
use Ndrx\Profiler\JsonPatch;
9
use Ndrx\Profiler\Process;
10
use Symfony\Component\HttpFoundation\Response as FoundationResponse;
11
12
/**
13
 * Created by PhpStorm.
14
 * User: arnaud
15
 * Date: 08/11/15
16
 * Time: 21:02
17
 */
18
class Http extends Response
19
{
20
21
    /**
22
     * @var  \Symfony\Component\HttpFoundation\Response
23
     */
24
    protected $response;
25
26
    /**
27
     * @param Process $process
28
     * @param DataSourceInterface $dataSource
29
     * @param JsonPatch|null $jsonPatch
30
     */
31 10
    public function __construct(Process $process, DataSourceInterface $dataSource, JsonPatch $jsonPatch = null)
32
    {
33 10
        parent::__construct($process, $dataSource, $jsonPatch);
34
35 10
        $this->process->getDispatcher()->addListener(HttpFoundationResponse::EVENT_NAME, function (HttpFoundationResponse $event) {
36 2
            $this->response = $event->getResponse();
37 10
        });
38 10
    }
39
40
    /**
41
     * @return int
42
     */
43 10
    public function getStatusCode()
44
    {
45 10
        if ($this->response === null) {
46 8
            return null;
47
        }
48
49 2
        return $this->response->getStatusCode();
50
    }
51
52
    /**
53
     * @return string
54
     */
55 10
    protected function getStatusText()
56
    {
57 10
        if ($this->response === null) {
58 8
            return null;
59
        }
60
61 2
        return FoundationResponse::$statusTexts[$this->getStatusCode()];
62
    }
63
64
    /**
65
     * @return string
66
     */
67 10
    protected function getCharset()
68
    {
69 10
        if ($this->response === null) {
70 8
            return null;
71
        }
72
73 2
        return $this->response->getCharset();
74
    }
75
76
    /**
77
     * @return int
78
     */
79 10
    protected function getMaxAge()
80
    {
81 10
        if ($this->response === null) {
82 8
            return null;
83
        }
84
85 2
        return $this->response->getMaxAge();
86
    }
87
88
    /**
89
     * @return int
90
     */
91 10
    protected function getExpires()
92
    {
93 10
        if ($this->response === null) {
94 8
            return null;
95
        }
96
97 2
        return $this->response->getExpires();
98
    }
99
100
    /**
101
     * @return \DateTime
102
     */
103 10
    protected function getLastModified()
104
    {
105 10
        if ($this->response === null) {
106 8
            return null;
107
        }
108
109 2
        return $this->response->getLastModified();
110
    }
111
112
    /**
113
     * @return int
114
     */
115 10
    protected function getTtl()
116
    {
117 10
        if ($this->response === null) {
118 8
            return null;
119
        }
120
121 2
        return $this->response->getTtl();
122
    }
123
}
124