• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aplus-framework / debug / 12309578219

07 Dec 2024 11:27PM UTC coverage: 97.273%. Remained the same
12309578219

push

github

natanfelles
Add height attribute to debugbar icon

1 of 1 new or added line in 1 file covered. (100.0%)

535 of 550 relevant lines covered (97.27%)

2.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Collection.php
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of Aplus Framework Debug Library.
4
 *
5
 * (c) Natan Felles <natanfelles@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Framework\Debug;
11

12
use RuntimeException;
13

14
/**
15
 * Class Collection.
16
 *
17
 * @package debug
18
 */
19
class Collection
20
{
21
    protected string $name;
22
    /**
23
     * @var array<Collector>
24
     */
25
    protected array $collectors = [];
26
    /**
27
     * @var array<string>
28
     */
29
    protected array $actions = [];
30
    protected string $icon = '';
31
    protected string $iconPath;
32

33
    public function __construct(string $name)
34
    {
35
        $this->name = $name;
7✔
36
        $this->prepare();
7✔
37
    }
38

39
    protected function prepare() : void
40
    {
41
        if (isset($this->iconPath)) {
7✔
42
            if (!\is_file($this->iconPath)) {
2✔
43
                throw new RuntimeException(
1✔
44
                    'Icon path is invalid: ' . $this->iconPath
1✔
45
                );
1✔
46
            }
47
            $this->setIcon((string) \file_get_contents($this->iconPath));
1✔
48
        }
49
    }
50

51
    public function getName() : string
52
    {
53
        return $this->name;
4✔
54
    }
55

56
    public function getSafeName() : string
57
    {
58
        return Debugger::makeSafeName($this->getName());
2✔
59
    }
60

61
    public function addCollector(Collector $collector) : static
62
    {
63
        $this->collectors[] = $collector;
3✔
64
        return $this;
3✔
65
    }
66

67
    /**
68
     * @return array<Collector>
69
     */
70
    public function getCollectors() : array
71
    {
72
        return $this->collectors;
3✔
73
    }
74

75
    public function addAction(string $action) : static
76
    {
77
        $this->actions[] = $action;
1✔
78
        return $this;
1✔
79
    }
80

81
    /**
82
     * @return array<string>
83
     */
84
    public function getActions() : array
85
    {
86
        return $this->actions;
2✔
87
    }
88

89
    public function hasCollectors() : bool
90
    {
91
        return !empty($this->collectors);
2✔
92
    }
93

94
    /**
95
     * @return array<int,array<int,array<string,mixed>>>
96
     */
97
    public function getActivities() : array
98
    {
99
        $result = [];
2✔
100
        foreach ($this->getCollectors() as $collector) {
2✔
101
            $activities = $collector->getActivities();
2✔
102
            if ($activities) {
2✔
103
                foreach ($activities as &$activity) {
1✔
104
                    $activity = \array_merge([
1✔
105
                        'collection' => $this->getName(),
1✔
106
                    ], $activity);
1✔
107
                }
108
                unset($activity);
1✔
109
                $result[] = $activities;
1✔
110
            }
111
        }
112
        return $result;
2✔
113
    }
114

115
    public function getIcon() : string
116
    {
117
        return $this->icon;
3✔
118
    }
119

120
    public function setIcon(string $icon) : static
121
    {
122
        $this->icon = $icon;
2✔
123
        return $this;
2✔
124
    }
125

126
    public function hasIcon() : bool
127
    {
128
        return $this->icon !== '';
2✔
129
    }
130
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc