TimersCollector   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 41
ccs 0
cts 6
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A formatTimelineData() 0 21 3
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Debug\Toolbar\Collectors;
13
14
/**
15
 * Collecteur de temporisateurs pour la barre d'outils de débogage
16
 *
17
 * @credit	<a href="https://codeigniter.com">CodeIgniter 4.2 - CodeIgniter\Debug\Toolbar\Collectors\Timers</a>
18
 */
19
class TimersCollector extends BaseCollector
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected bool $hasTimeline = true;
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    protected bool $hasTabContent = false;
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    protected string $title = 'Timers';
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    protected function formatTimelineData(): array
40
    {
41
        $data = [];
42
43
        $benchmark = single_service('timer');
44
        $rows      = $benchmark->getTimers(6);
45
46
        foreach ($rows as $name => $info) {
47
            if ($name === 'total_execution') {
48
                continue;
49
            }
50
51
            $data[] = [
52
                'name'      => ucwords(str_replace('_', ' ', $name)),
53
                'component' => 'Timer',
54
                'start'     => $info['start'],
55
                'duration'  => $info['end'] - $info['start'],
56
            ];
57
        }
58
59
        return $data;
60
    }
61
}
62