Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
Collector
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSafeName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addData
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getActivities
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContents
n/a
0 / 0
n/a
0 / 0
0
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 */
10namespace Framework\Debug;
11
12/**
13 * Class Collector.
14 *
15 * @package debug
16 */
17abstract class Collector
18{
19    protected string $name;
20    /**
21     * @var array<mixed>
22     */
23    protected array $data = [];
24    /**
25     * @var array<int,array<string,mixed>>
26     */
27    protected array $activities = [];
28
29    public function __construct(string $name = 'default')
30    {
31        $this->name = $name;
32    }
33
34    public function getName() : string
35    {
36        return $this->name;
37    }
38
39    public function getSafeName() : string
40    {
41        return Debugger::makeSafeName($this->getName());
42    }
43
44    /**
45     * @param array<mixed> $data
46     *
47     * @return static
48     */
49    public function addData(array $data) : static
50    {
51        $this->data[] = $data;
52        return $this;
53    }
54
55    /**
56     * @return array<mixed>
57     */
58    public function getData() : array
59    {
60        return $this->data;
61    }
62
63    public function hasData() : bool
64    {
65        return ! empty($this->data);
66    }
67
68    /**
69     * @return array<int,array<string,mixed>>
70     */
71    public function getActivities() : array
72    {
73        return $this->activities;
74    }
75
76    abstract public function getContents() : string;
77}