Passed
Pull Request — master (#38)
by Christophe
02:59
created

Chart   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 95.65%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 2
dl 0
loc 145
ccs 22
cts 23
cp 0.9565
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
getType() 0 1 ?
getPackage() 0 1 ?
getAvailableEventTypes() 0 1 ?
getOptions() 0 1 ?
setOptions() 0 1 ?
A __construct() 0 5 1
A getName() 0 8 2
A getDataName() 0 4 1
A getOptionsName() 0 4 1
A getLibrary() 0 4 1
A setElementID() 0 6 1
A getElementID() 0 4 1
A getData() 0 4 1
A getEvents() 0 4 1
1
<?php
2
3
namespace CMEN\GoogleChartsBundle\GoogleCharts;
4
5
use CMEN\GoogleChartsBundle\GoogleCharts\Options\ChartOptionsInterface;
6
7
/**
8
 * @author Christophe Meneses
9
 */
10
abstract class Chart
11
{
12
    /**
13
     * @var string|null
14
     */
15
    protected $elementID;
16
17
    /**
18
     * @var Data
19
     */
20
    protected $data;
21
22
    /**
23
     * @var ChartOptionsInterface
24
     */
25
    protected $options;
26
27
    /**
28
     * @var Events
29
     */
30
    protected $events;
31
32 13
    public function __construct()
33
    {
34 13
        $this->data = new Data();
35 13
        $this->events = new Events($this);
36 13
    }
37
38
    /**
39
     * Returns chart's name.
40
     *
41
     * @return string
42
     */
43 4
    public function getName()
44
    {
45 4
        if (null === $this->elementID) {
46
            return '';
47
        }
48
49 4
        return 'chart'.ucfirst($this->elementID);
50
    }
51
52
    /**
53
     * Returns data chart's name.
54
     *
55
     * @return string
56
     */
57 4
    public function getDataName()
58
    {
59 4
        return 'data'.ucfirst($this->getName());
60
    }
61
62
    /**
63
     * Returns options chart's name.
64
     *
65
     * @return string
66
     */
67 4
    public function getOptionsName()
68
    {
69 4
        return 'options'.ucfirst($this->getName());
70
    }
71
72
    /**
73
     * Returns the chart type.
74
     *
75
     * @return string
76
     */
77
    abstract public function getType();
78
79
    /**
80
     * Returns library used by chart.
81
     *
82
     * @return string
83
     */
84 4
    public function getLibrary()
85
    {
86 4
        return 'visualization';
87
    }
88
89
    /**
90
     * Returns the chart package.
91
     *
92
     * @return string
93
     */
94
    abstract public function getPackage();
95
96
    /**
97
     * Returns available event types.
98
     *
99
     * @return string[]
100
     */
101
    abstract public function getAvailableEventTypes();
102
103
    /**
104
     * Returns the instance options.
105
     *
106
     * @return ChartOptionsInterface
107
     */
108
    abstract public function getOptions();
109
110
    /**
111
     * Sets the instance Options.
112
     *
113
     * @param ChartOptionsInterface $options
114
     *
115
     * @return ChartOptionsInterface
116
     */
117
    abstract public function setOptions($options);
118
119
    /**
120
     * @param string $elementID
121
     *
122
     * @return $this
123
     */
124 4
    public function setElementID($elementID)
125
    {
126 4
        $this->elementID = $elementID;
127
128 4
        return $this;
129
    }
130
131
    /**
132
     * @return string|null
133
     */
134 5
    public function getElementID()
135
    {
136 5
        return $this->elementID;
137
    }
138
139
    /**
140
     * @return Data
141
     */
142 5
    public function getData()
143
    {
144 5
        return $this->data;
145
    }
146
147
    /**
148
     * @return Events
149
     */
150 4
    public function getEvents()
151
    {
152 4
        return $this->events;
153
    }
154
}
155