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

aplus-framework / debug / 5102359423

pending completion
5102359423

push

github

natanfelles
Add Debugger::roundVersion method

513 of 515 relevant lines covered (99.61%)

2.61 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
/**
13
 * Class Collection.
14
 *
15
 * @package debug
16
 */
17
class Collection
18
{
19
    protected string $name;
20
    /**
21
     * @var array<Collector>
22
     */
23
    protected array $collectors = [];
24
    /**
25
     * @var array<string>
26
     */
27
    protected array $actions = [];
28

29
    public function __construct(string $name)
30
    {
31
        $this->name = $name;
4✔
32
    }
33

34
    public function getName() : string
35
    {
36
        return $this->name;
4✔
37
    }
38

39
    public function getSafeName() : string
40
    {
41
        return Debugger::makeSafeName($this->getName());
2✔
42
    }
43

44
    public function addCollector(Collector $collector) : static
45
    {
46
        $this->collectors[] = $collector;
3✔
47
        return $this;
3✔
48
    }
49

50
    /**
51
     * @return array<Collector>
52
     */
53
    public function getCollectors() : array
54
    {
55
        return $this->collectors;
3✔
56
    }
57

58
    public function addAction(string $action) : static
59
    {
60
        $this->actions[] = $action;
1✔
61
        return $this;
1✔
62
    }
63

64
    /**
65
     * @return array<string>
66
     */
67
    public function getActions() : array
68
    {
69
        return $this->actions;
2✔
70
    }
71

72
    public function hasCollectors() : bool
73
    {
74
        return ! empty($this->collectors);
2✔
75
    }
76

77
    /**
78
     * @return array<int,array<int,array<string,mixed>>>
79
     */
80
    public function getActivities() : array
81
    {
82
        $result = [];
2✔
83
        foreach ($this->getCollectors() as $collector) {
2✔
84
            $activities = $collector->getActivities();
2✔
85
            if ($activities) {
2✔
86
                foreach ($activities as &$activity) {
1✔
87
                    $activity = \array_merge([
1✔
88
                        'collection' => $this->getName(),
1✔
89
                    ], $activity);
1✔
90
                }
91
                unset($activity);
1✔
92
                $result[] = $activities;
1✔
93
            }
94
        }
95
        return $result;
2✔
96
    }
97
}
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