Test Failed
Push — master ( d818fc...2d2f9a )
by Christophe
08:50
created

Chart::startDraw()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.4098

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 9
cts 14
cp 0.6429
rs 9.0856
c 0
b 0
f 0
cc 3
eloc 15
nc 3
nop 0
crap 3.4098

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Chart::getElementID() 0 4 1
A Chart::getData() 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
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
    /**
33
     * Chart constructor.
34
     */
35
    public function __construct()
36
    {
37
        $this->data = new Data();
38 3
        $this->events = new Events($this);
39
    }
40 3
41 3
    /**
42 3
     * Returns chart's name.
43
     *
44
     * @return string
45
     */
46
    public function getName()
47
    {
48
        return 'chart'.ucfirst($this->elementID);
49
    }
50 2
51
    /**
52 2
     * Returns data chart's name.
53
     *
54
     * @return string
55
     */
56
    public function getDataName()
57
    {
58
        return 'data'.ucfirst($this->getName());
59
    }
60 2
61
    /**
62 2
     * Returns options chart's name.
63
     *
64
     * @return string
65
     */
66
    public function getOptionsName()
67
    {
68
        return 'options'.ucfirst($this->getName());
69
    }
70 1
71
    /**
72 1
     * Returns the chart type.
73
     *
74
     * @return string
75
     */
76
    abstract public function getType();
77
78
    /**
79
     * Returns library used by chart.
80
     *
81
     * @return string
82
     */
83
    public function getLibrary()
84
    {
85
        return 'visualization';
86
    }
87 2
88
    /**
89 2
     * Returns the chart package.
90
     *
91
     * @return string
92
     */
93
    abstract public function getPackage();
94
95
    /**
96
     * Returns the instance options.
97
     */
98
    abstract public function getOptions();
99
100
    /**
101
     * Sets the instance Options.
102
     *
103
     * @param ChartOptionsInterface $options
104
     *
105
     * @return ChartOptionsInterface
106
     */
107
    abstract public function setOptions($options);
108
109
    /**
110
     * @param string $elementID
111
     *
112
     * @return $this
113
     */
114
    public function setElementID($elementID)
115
    {
116
        $this->elementID = $elementID;
117
118
        return $this;
119
    }
120 3
121
    /**
122 3
     * @return string
123 1
     */
124
    public function getElementID()
125
    {
126 2
        return $this->elementID;
127 2
    }
128
129 2
    /**
130 2
     * @return Data
131 1
     */
132
    public function getData()
133
    {
134
        return $this->data;
135
    }
136
137
    /**
138
     * @return Events
139 1
     */
140
    public function getEvents()
141 1
    {
142
        return $this->events;
143
    }
144
}
145