1 | <?php |
||
11 | abstract class AbstractChartOutput implements ChartOutputInterface |
||
12 | { |
||
13 | /** |
||
14 | * Version of Google Charts used. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $version; |
||
19 | |||
20 | /** |
||
21 | * Locale to customize currencies, dates, and numbers. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $language; |
||
26 | |||
27 | /** |
||
28 | * @param string $version |
||
29 | * @param string $language |
||
30 | */ |
||
31 | 14 | public function __construct($version, $language) |
|
32 | { |
||
33 | 14 | $this->version = $version; |
|
34 | 14 | $this->language = $language; |
|
35 | 14 | } |
|
36 | |||
37 | /** |
||
38 | * @param string $language |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function setLanguage($language) |
||
43 | { |
||
44 | $this->language = $language; |
||
45 | |||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Checks if all elements ID are string and same number as charts. |
||
51 | * |
||
52 | * @param Chart[] $charts |
||
53 | * @param string[] $elementsID |
||
54 | * |
||
55 | * @return void |
||
56 | * |
||
57 | * @throws GoogleChartsException |
||
58 | */ |
||
59 | 2 | protected function checkElementsId(array $charts, array $elementsID) |
|
60 | { |
||
61 | 2 | if (count($charts) != count($elementsID)) { |
|
62 | 1 | throw new GoogleChartsException('Array charts and array HTML elements ID do not have the same number of element.'); |
|
63 | } |
||
64 | |||
65 | 1 | foreach ($elementsID as $elementId) { |
|
66 | 1 | if (!is_string($elementId)) { |
|
67 | 1 | throw new GoogleChartsException('A string is expected for HTML element ID.'); |
|
68 | } |
||
69 | } |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Checks if all elements of an array are instances of Chart. Throws an exception if not. |
||
74 | * |
||
75 | * @param Chart[] $charts |
||
76 | * |
||
77 | * @return void |
||
78 | * |
||
79 | * @throws GoogleChartsException |
||
80 | */ |
||
81 | 4 | protected function checkChartsTypes(array $charts) |
|
89 | } |
||
90 |