Chart::getOptionsName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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
    protected ?string $elementID = null;
13
14
    protected Data $data;
15
16
    protected ChartOptionsInterface $options;
17
18
    protected Events $events;
19
20 13
    public function __construct()
21
    {
22 13
        $this->data = new Data();
23 13
        $this->events = new Events($this);
24
    }
25
26
    /**
27
     * Returns chart's name.
28
     */
29 4
    public function getName(): string
30
    {
31 4
        if (null === $this->elementID) {
32
            return '';
33
        }
34
35 4
        return 'chart'.ucfirst($this->elementID);
36
    }
37
38
    /**
39
     * Returns data chart's name.
40
     */
41 4
    public function getDataName(): string
42
    {
43 4
        return 'data'.ucfirst($this->getName());
44
    }
45
46
    /**
47
     * Returns options chart's name.
48
     */
49 4
    public function getOptionsName(): string
50
    {
51 4
        return 'options'.ucfirst($this->getName());
52
    }
53
54
    /**
55
     * Returns the chart type.
56
     */
57
    abstract public function getType(): string;
58
59
    /**
60
     * Returns library used by chart.
61
     */
62 4
    public function getLibrary(): string
63
    {
64 4
        return 'visualization';
65
    }
66
67
    /**
68
     * Returns the chart package.
69
     */
70
    abstract public function getPackage(): string;
71
72
    /**
73
     * Returns available event types.
74
     *
75
     * @return string[]
76
     */
77
    abstract public function getAvailableEventTypes(): array;
78
79
    /**
80
     * Returns the instance options.
81
     */
82
    abstract public function getOptions(): ChartOptionsInterface;
83
84
    /**
85
     * Sets the instance Options.
86
     */
87
    abstract public function setOptions(ChartOptionsInterface $options): Chart;
88
89 4
    public function setElementID(string $elementID): Chart
90
    {
91 4
        $this->elementID = $elementID;
92
93 4
        return $this;
94
    }
95
96 5
    public function getElementID(): ?string
97
    {
98 5
        return $this->elementID;
99
    }
100
101 5
    public function getData(): Data
102
    {
103 5
        return $this->data;
104
    }
105
106 4
    public function getEvents(): Events
107
    {
108 4
        return $this->events;
109
    }
110
}
111