Events::prepare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spiral\Statistics\Extract;
4
5
use Spiral\Statistics\Extract\Events\Row;
6
7
class Events
8
{
9
    /** @var array */
10
    protected $events = [];
11
12
    /** @var array */
13
    protected $rows = [];
14
15
    /**
16
     * Results constructor.
17
     *
18
     * @param array $events
19
     */
20
    public function __construct(array $events)
21
    {
22
        $this->events = $events;
23
    }
24
25
    /**
26
     * @param string $label
27
     * @return Row
28
     */
29
    public function addRow(string $label): Row
30
    {
31
        $row = new Row($label, $this->events);
32
        $this->rows[$label] = $row;
33
34
        return $row;
35
    }
36
37
    /**
38
     * @param DatasetInterface $dataset
39
     * @return DatasetInterface
40
     */
41
    public function prepare(DatasetInterface $dataset): DatasetInterface
42
    {
43
        $dataset->setData($this->rows);
44
45
        return $dataset;
46
    }
47
}