|
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
|
|
|
|