1 | <?php |
||
14 | class Display |
||
15 | { |
||
16 | |||
17 | /** @var array */ |
||
18 | protected $defaults = array( |
||
19 | 'script_path' => 'asset/script.js', |
||
20 | 'style_path' => 'asset/style.css' |
||
21 | ); |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $options; |
||
25 | |||
26 | /** @var double */ |
||
27 | protected $startTime; |
||
28 | |||
29 | /** @var Console */ |
||
30 | protected $console; |
||
31 | |||
32 | /** @var array */ |
||
33 | protected $speedData; |
||
34 | |||
35 | /** @var array */ |
||
36 | protected $queryData; |
||
37 | |||
38 | /** @var array */ |
||
39 | protected $memoryData; |
||
40 | |||
41 | /** @var array */ |
||
42 | protected $fileData; |
||
43 | |||
44 | /** |
||
45 | * @param array $options |
||
46 | */ |
||
47 | public function __construct(array $options = array()) |
||
52 | |||
53 | /** |
||
54 | * @param double $startTime |
||
55 | */ |
||
56 | public function setStartTime($startTime) |
||
60 | |||
61 | /** |
||
62 | * @param Console $console |
||
63 | */ |
||
64 | public function setConsole(Console $console) |
||
68 | |||
69 | /** |
||
70 | * Sets memory data |
||
71 | * |
||
72 | * @param array $data |
||
73 | */ |
||
74 | public function setMemoryData(array $data) |
||
78 | |||
79 | /** |
||
80 | * Sets query data |
||
81 | * |
||
82 | * @param array $data |
||
83 | */ |
||
84 | public function setQueryData(array $data) |
||
88 | |||
89 | /** |
||
90 | * Sets speed data |
||
91 | * |
||
92 | * @param array $data |
||
93 | */ |
||
94 | public function setSpeedData(array $data) |
||
98 | |||
99 | /** |
||
100 | * Sets file data |
||
101 | * |
||
102 | * @param array $data |
||
103 | */ |
||
104 | public function setFileData(array $data) |
||
108 | |||
109 | /** |
||
110 | * @return array |
||
111 | */ |
||
112 | protected function getConsoleMeta() |
||
113 | { |
||
114 | $consoleMeta = array( |
||
115 | 'log' => 0, |
||
116 | 'memory' => 0, |
||
117 | 'error' => 0, |
||
118 | 'speed' => 0 |
||
119 | ); |
||
120 | foreach ($this->console->getLogs() as $log) { |
||
121 | if (array_key_exists($log['type'], $consoleMeta)) { |
||
122 | $consoleMeta[$log['type']]++; |
||
123 | continue; |
||
124 | } |
||
125 | $consoleMeta['error']++; |
||
126 | } |
||
127 | |||
128 | return $consoleMeta; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return array |
||
133 | */ |
||
134 | protected function getConsoleMessages() |
||
177 | |||
178 | /** |
||
179 | * @return array |
||
180 | */ |
||
181 | protected function getSpeedMeta() |
||
191 | |||
192 | /** |
||
193 | * @return array |
||
194 | */ |
||
195 | public function getQueryMeta() |
||
213 | |||
214 | /** |
||
215 | * @return array |
||
216 | */ |
||
217 | public function getQueryList() |
||
229 | |||
230 | /** |
||
231 | * @return array |
||
232 | */ |
||
233 | public function getMemoryMeta() |
||
243 | |||
244 | /** |
||
245 | * @return array |
||
246 | */ |
||
247 | protected function getFileMeta() |
||
265 | |||
266 | /** |
||
267 | * @return array |
||
268 | */ |
||
269 | protected function getFileList() |
||
280 | |||
281 | /** |
||
282 | * Formatter for human-readable time |
||
283 | * Only handles time up to 60 minutes gracefully |
||
284 | * |
||
285 | * @param double $time |
||
286 | * @param integer $percision |
||
287 | * @return string |
||
288 | */ |
||
289 | protected function getReadableTime($time, $percision = 3) |
||
302 | |||
303 | /** |
||
304 | * Formatter for human-readable memory |
||
305 | * Only handles time up to a few gigs gracefully |
||
306 | * |
||
307 | * @param double $size |
||
308 | * @param integer $percision |
||
309 | */ |
||
310 | protected function getReadableMemory($size, $percision = 2) |
||
320 | |||
321 | /** |
||
322 | * @param array $messages |
||
323 | * @param string $type |
||
324 | * @return array |
||
325 | */ |
||
326 | protected function filterMessages($messages, $type) |
||
332 | |||
333 | /** |
||
334 | * @returns array |
||
335 | */ |
||
336 | protected function gatherTemplateData() |
||
378 | |||
379 | public function __invoke() |
||
392 | } |
||
393 |