LeftAndMainExtension   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 3
A accessedCMS() 0 12 3
1
<?php
2
3
namespace LeKoala\DebugBar\Extension;
4
5
use LeKoala\DebugBar\DebugBar;
6
use SilverStripe\Core\Extension;
7
8
/**
9
 * @author Koala
10
 */
11
class LeftAndMainExtension extends Extension
12
{
13
    public function accessedCMS()
14
    {
15
        DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) {
16
            /** @var DebugBar\DataCollector\TimeDataCollector $timeData */
17
            $timeData = $debugbar->getCollector('time');
18
            if (!$timeData) {
0 ignored issues
show
introduced by
$timeData is of type LeKoala\DebugBar\DebugBa...ector\TimeDataCollector, thus it always evaluated to true.
Loading history...
19
                return;
20
            }
21
            if ($timeData->hasStartedMeasure("init")) {
22
                $timeData->stopMeasure("init");
23
            }
24
            $timeData->startMeasure("cms_accessed", "cms accessed");
25
        });
26
    }
27
28
    public function init()
29
    {
30
        DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) {
31
            /** @var DebugBar\DataCollector\TimeDataCollector $timeData */
32
            $timeData = $debugbar->getCollector('time');
33
            if (!$timeData) {
0 ignored issues
show
introduced by
$timeData is of type LeKoala\DebugBar\DebugBa...ector\TimeDataCollector, thus it always evaluated to true.
Loading history...
34
                return;
35
            }
36
            if ($timeData->hasStartedMeasure("cms_accessed")) {
37
                $timeData->stopMeasure("cms_accessed");
38
            }
39
            $timeData->startMeasure("cms_init", "cms init");
40
        });
41
    }
42
}
43