Response   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 89.47%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 4
c 5
b 0
f 1
lcom 1
cbo 2
dl 0
loc 91
ccs 17
cts 19
cp 0.8947
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 4 1
A resolve() 0 14 1
A getDataFields() 0 6 1
A getRenderer() 0 4 1
getStatusCode() 0 1 ?
getStatusText() 0 1 ?
getCharset() 0 1 ?
getMaxAge() 0 1 ?
getExpires() 0 1 ?
getLastModified() 0 1 ?
getTtl() 0 1 ?
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 08/11/15
6
 * Time: 20:52
7
 */
8
9
namespace Ndrx\Profiler\Collectors\Data;
10
11
use Ndrx\Profiler\Collectors\Collector;
12
use Ndrx\Profiler\Collectors\Contracts\FinalCollectorInterface;
13
use Ndrx\Profiler\Renderer\BarRenderableInterface;
14
use Ndrx\Profiler\Renderer\RendererInterface;
15
16
abstract class Response extends Collector implements FinalCollectorInterface, BarRenderableInterface
17
{
18
19
    /**
20
     * The path in the final json
21
     * @example
22
     *  path /aa/bb
23
     *  will be transformed to
24
     *  {
25
     *     aa : {
26
     *              bb: <VALUE OF RESOLVE>
27
     *       }
28
     *  }
29
     * @return mixed
30
     */
31 6
    public function getPath()
32
    {
33 6
        return 'response';
34
    }
35
36
    /**
37
     * Fetch data
38
     * @return void
39
     */
40 10
    public function resolve()
41
    {
42 10
        $this->data = [
43
            'status' => [
44 10
                'code' => $this->getStatusCode(),
45 10
                'text' => $this->getStatusText(),
46 10
            ],
47 10
            'charset' => $this->getCharset(),
48 10
            'maxAge' => $this->getMaxAge(),
49 10
            'expires' => $this->getExpires(),
50 10
            'lastModified' => $this->getLastModified(),
51 10
            'ttl' => $this->getTtl()
52 10
        ];
53 10
    }
54
55 10
    public function getDataFields()
56
    {
57
        return [
58 10
            'status', 'charset', 'maxAge', 'expires', 'lastModified', 'ttl'
59 10
        ];
60
    }
61
62
    /**
63
     * @return RendererInterface
64
     *
65
     * @throws \RuntimeException
66
     */
67
    public function getRenderer()
68
    {
69
        return new \Ndrx\Profiler\Renderer\Html\Data\Response();
70
    }
71
72
    /**
73
     * @return int
74
     */
75
    abstract public function getStatusCode();
76
77
    /**
78
     * @return string
79
     */
80
    abstract protected function getStatusText();
81
82
    /**
83
     * @return string
84
     */
85
    abstract protected function getCharset();
86
87
    /**
88
     * @return int
89
     */
90
    abstract protected function getMaxAge();
91
92
    /**
93
     * @return int
94
     */
95
    abstract protected function getExpires();
96
97
    /**
98
     * @return \DateTime
99
     */
100
    abstract protected function getLastModified();
101
102
    /**
103
     * @return int
104
     */
105
    abstract protected function getTtl();
106
}
107