QueryResult   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 83
ccs 18
cts 21
cp 0.8571
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getTotals() 0 4 1
A getDetails() 0 7 2
A hasDetails() 0 4 1
A getRows() 0 4 1
A getColumns() 0 4 1
A getAggregates() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
namespace EngineWorks\Pivot;
4
5
class QueryResult
6
{
7
    /** @var Result */
8
    private $totals;
9
10
    /** @var Result */
11
    private $details;
12
13
    /** @var array */
14
    private $rows;
15
16
    /** @var array */
17
    private $columns;
18
19
    /** @var array */
20
    private $aggregates;
21
22
    /**
23
     * QueryResult constructor.
24
     * @param Result $totals
25
     * @param Result|null $details
26
     * @param array $rows
27
     * @param array $columns
28
     * @param array $aggregates
29
     */
30 9
    public function __construct(Result $totals, $details, array $rows, array $columns, array $aggregates)
31
    {
32 9
        $this->totals = $totals;
33 9
        $this->details = ($details instanceof Result) ? $details : null;
34 9
        $this->rows = $rows;
35 9
        $this->columns = $columns;
36 9
        $this->aggregates = $aggregates;
37 9
    }
38
39
    /**
40
     * @return Result
41
     */
42 9
    public function getTotals(): Result
43
    {
44 9
        return $this->totals;
45
    }
46
47
    /**
48
     * @return Result
49
     * @throws PivotException if there are not details
50
     */
51 5
    public function getDetails(): Result
52
    {
53 5
        if (null === $this->details) {
54
            throw new PivotException('The result does not have details');
55
        }
56 5
        return $this->details;
57
    }
58
59 9
    public function hasDetails() : bool
60
    {
61 9
        return (null !== $this->details);
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function getRows(): array
68
    {
69
        return $this->rows;
70
    }
71
72
    /**
73
     * @return array
74
     */
75 1
    public function getColumns(): array
76
    {
77 1
        return $this->columns;
78
    }
79
80
    /**
81
     * @return array
82
     */
83 1
    public function getAggregates(): array
84
    {
85 1
        return $this->aggregates;
86
    }
87
}
88