Conditions | 4 |
Paths | 5 |
Total Lines | 30 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
30 | 2 | public function draw(ChartOptionsInterface $options, $optionsName) |
|
31 | { |
||
32 | 2 | $this->removeRecursivelyNullValue($options); |
|
33 | |||
34 | /* @var array $options */ |
||
35 | 2 | $this->removeRecursivelyEmptyArray($options); |
|
36 | |||
37 | 2 | $options = $this->renameRecursivelyKeys($options); |
|
38 | |||
39 | 2 | $js = "var $optionsName = {"; |
|
40 | |||
41 | 2 | end($options); |
|
42 | 2 | $lastKey = key($options); |
|
43 | 2 | foreach ($options as $optionKey => $optionValue) { |
|
44 | 2 | $js .= '"'.$optionKey.'":'; |
|
45 | |||
46 | 2 | if (isset($optionValue['date'])) { |
|
47 | 1 | $js .= $this->dateOutput->draw(new \DateTime($optionValue['date'])); |
|
48 | 1 | } else { |
|
49 | 2 | $js .= json_encode($optionValue); |
|
50 | } |
||
51 | |||
52 | 2 | if ($optionKey != $lastKey) { |
|
53 | 2 | $js .= ', '; |
|
54 | 2 | } |
|
55 | 2 | } |
|
56 | 2 | $js .= "};\n"; |
|
57 | |||
58 | 2 | return $js; |
|
59 | } |
||
60 | } |
||
61 |