LogsCollector::collectLogs()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 2
cp 0
crap 6
rs 10
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 logs pour la barre d'outils de débogage
16
 *
17
 * @credit	<a href="https://codeigniter.com">CodeIgniter 4.2 - CodeIgniter\Debug\Toolbar\Collectors\Logs</a>
18
 */
19
class LogsCollector extends BaseCollector
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected bool $hasTimeline = false;
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    protected bool $hasTabContent = true;
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    protected string $title = 'Logs';
35
36
    /**
37
     * Nos données collectées
38
     */
39
    protected array $data = [];
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    public function display(): array
45
    {
46
        return [
47
            'logs' => $this->collectLogs(),
48
        ];
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function isEmpty(): bool
55
    {
56
        $this->collectLogs();
57
58
        return $this->data === [];
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     *
64
     * Icon from https://icons8.com - 1em package
65
     */
66
    public function icon(): string
67
    {
68
        return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACYSURBVEhLYxgFJIHU1FSjtLS0i0D8AYj7gEKMEBkqAaAFF4D4ERCvAFrwH4gDoFIMKSkpFkB+OTEYqgUTACXfA/GqjIwMQyD9H2hRHlQKJFcBEiMGQ7VgAqCBvUgK32dmZspCpagGGNPT0/1BLqeF4bQHQJePpiIwhmrBBEADR1MRfgB0+WgqAmOoFkwANHA0FY0CUgEDAwCQ0PUpNB3kqwAAAABJRU5ErkJggg==';
69
    }
70
71
    /**
72
     * S'assure que les données ont été collectées.
73
     */
74
    protected function collectLogs()
75
    {
76
        if ($this->data !== []) {
77
            return $this->data;
78
        }
79
80
        return $this->data = single_service('logger')->logCache;
81
    }
82
}
83