YearGraphicalData   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 71
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getYear() 0 4 1
A addType() 0 6 1
A addGraphicalValue() 0 8 2
A export() 0 14 3
1
<?php
2
/**
3
 *
4
 */
5
6
/**
7
 * YearGraphicalData class
8
 *
9
 * @author Laurent De Coninck <[email protected]>
10
 */
11
class YearGraphicalData
12
{
13
14
    /**
15
     * @var int
16
     */
17
    private $year;
18
19
    /**
20
     * @var GraphicalValueType[]
21
     */
22
    private $graphData;
23
24
    /**
25
     *
26
     * @param int $year
27
     */
28
    public function __construct($year)
29
    {
30
        $this->year = $year;
31
        $this->graphData = [];
32
    }
33
34
    /**
35
     * @return int
36
     */
37
    public function getYear()
38
    {
39
        return $this->year;
40
    }
41
42
    /**
43
     * @param GraphicalType $graphicalType
44
     */
45
    public function addType(GraphicalType $graphicalType)
46
    {
47
48
        $this->graphData[$graphicalType->getId()] = new GraphicalValueType($graphicalType,
49
            new GraphicalValue(0, $this->year, $graphicalType->getId()));
50
    }
51
52
    /**
53
     * @param GraphicalValue $graphicalValue
54
     */
55
    public function addGraphicalValue(GraphicalValue $graphicalValue)
56
    {
57
        if (!isset($this->graphData[$graphicalValue->getType()])) {
58
            return;
59
        }
60
61
        $this->graphData[$graphicalValue->getType()]->addValue($graphicalValue);
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function export()
68
    {
69
        $result = [$this->year];
70
71
        foreach ($this->graphData as $typeId => $data) {
72
            if(!in_array($typeId, [1,2,3,6])){
73
                continue;
74
            }
75
76
            $result[] = $data->getValue();
77
        }
78
79
        return $result;
80
    }
81
}