@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array &$arr |
43 | 43 | * @param string $path |
44 | 44 | * @param string $val |
45 | - * @return array |
|
45 | + * @return string |
|
46 | 46 | */ |
47 | 47 | protected function dotNotationToArray(array &$arr, $path, $val) |
48 | 48 | { |
@@ -6,55 +6,55 @@ |
||
6 | 6 | |
7 | 7 | class Subset implements Renderable { |
8 | 8 | |
9 | - /** |
|
10 | - * [__construct description] |
|
11 | - * @param \EnergieProduction\Chart\Contracts\Renderable $render |
|
12 | - */ |
|
13 | - public function __construct(Renderable $render) |
|
14 | - { |
|
15 | - $this->render = $render; |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * [handle description] |
|
20 | - * @param string $key |
|
21 | - * @param mixed $content |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function handle($key, $content) |
|
25 | - { |
|
26 | - if (str_contains($key, '.')) { |
|
27 | - |
|
28 | - $path = explode('.', $key); |
|
29 | - |
|
30 | - $result = []; |
|
31 | - |
|
32 | - $this->dotNotationToArray($result, $path, $content); |
|
33 | - |
|
34 | - return $this->render->handle($path[0], $result); |
|
35 | - } |
|
36 | - |
|
37 | - return $this->render->handle($key, $content); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * [dotNotationToArray description] |
|
42 | - * @param array &$arr |
|
43 | - * @param string $path |
|
44 | - * @param string $val |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - protected function dotNotationToArray(array &$arr, $path, $val) |
|
48 | - { |
|
49 | - $loc = &$arr; |
|
50 | - |
|
51 | - array_shift($path); |
|
52 | - |
|
53 | - foreach($path as $step) |
|
54 | - { |
|
55 | - $loc = &$loc[$step]; |
|
56 | - } |
|
9 | + /** |
|
10 | + * [__construct description] |
|
11 | + * @param \EnergieProduction\Chart\Contracts\Renderable $render |
|
12 | + */ |
|
13 | + public function __construct(Renderable $render) |
|
14 | + { |
|
15 | + $this->render = $render; |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * [handle description] |
|
20 | + * @param string $key |
|
21 | + * @param mixed $content |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function handle($key, $content) |
|
25 | + { |
|
26 | + if (str_contains($key, '.')) { |
|
27 | + |
|
28 | + $path = explode('.', $key); |
|
29 | + |
|
30 | + $result = []; |
|
31 | + |
|
32 | + $this->dotNotationToArray($result, $path, $content); |
|
33 | + |
|
34 | + return $this->render->handle($path[0], $result); |
|
35 | + } |
|
36 | + |
|
37 | + return $this->render->handle($key, $content); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * [dotNotationToArray description] |
|
42 | + * @param array &$arr |
|
43 | + * @param string $path |
|
44 | + * @param string $val |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + protected function dotNotationToArray(array &$arr, $path, $val) |
|
48 | + { |
|
49 | + $loc = &$arr; |
|
50 | + |
|
51 | + array_shift($path); |
|
52 | + |
|
53 | + foreach($path as $step) |
|
54 | + { |
|
55 | + $loc = &$loc[$step]; |
|
56 | + } |
|
57 | 57 | |
58 | - return $loc = $val; |
|
59 | - } |
|
58 | + return $loc = $val; |
|
59 | + } |
|
60 | 60 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | |
51 | 51 | array_shift($path); |
52 | 52 | |
53 | - foreach($path as $step) |
|
53 | + foreach ($path as $step) |
|
54 | 54 | { |
55 | 55 | $loc = &$loc[$step]; |
56 | 56 | } |
@@ -6,36 +6,36 @@ |
||
6 | 6 | |
7 | 7 | abstract class Builder implements Criteria { |
8 | 8 | |
9 | - protected $content; |
|
10 | - |
|
11 | - /** |
|
12 | - * [__construct description] |
|
13 | - * @param mixed $content |
|
14 | - */ |
|
15 | - public function __construct($content) |
|
16 | - { |
|
17 | - $this->content = $content; |
|
18 | - } |
|
19 | - |
|
20 | - /** |
|
21 | - * [resolveKey description] |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function resolveKey() |
|
25 | - { |
|
26 | - if (isset($this->key)) { |
|
27 | - return $this->key; |
|
28 | - } |
|
29 | - |
|
30 | - return lcfirst(class_basename(get_class($this))); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * [getContent description] |
|
35 | - * @return mixed |
|
36 | - */ |
|
37 | - public function getContent() |
|
38 | - { |
|
39 | - return $this->content; |
|
40 | - } |
|
9 | + protected $content; |
|
10 | + |
|
11 | + /** |
|
12 | + * [__construct description] |
|
13 | + * @param mixed $content |
|
14 | + */ |
|
15 | + public function __construct($content) |
|
16 | + { |
|
17 | + $this->content = $content; |
|
18 | + } |
|
19 | + |
|
20 | + /** |
|
21 | + * [resolveKey description] |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function resolveKey() |
|
25 | + { |
|
26 | + if (isset($this->key)) { |
|
27 | + return $this->key; |
|
28 | + } |
|
29 | + |
|
30 | + return lcfirst(class_basename(get_class($this))); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * [getContent description] |
|
35 | + * @return mixed |
|
36 | + */ |
|
37 | + public function getContent() |
|
38 | + { |
|
39 | + return $this->content; |
|
40 | + } |
|
41 | 41 | } |
@@ -12,19 +12,19 @@ |
||
12 | 12 | * [__construct description] |
13 | 13 | * @param \EnergieProduction\Chart\Contracts\Renderable $render |
14 | 14 | */ |
15 | - public function __construct(Renderable $render) |
|
16 | - { |
|
17 | - $this->render = $render; |
|
18 | - } |
|
15 | + public function __construct(Renderable $render) |
|
16 | + { |
|
17 | + $this->render = $render; |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * [handle description] |
|
22 | - * @param string $key |
|
23 | - * @param mixed $content |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function handle($key, $content) |
|
27 | - { |
|
28 | - return $this->render->handle($key, "#!!" . $content->render() . "!!#"); |
|
29 | - } |
|
20 | + /** |
|
21 | + * [handle description] |
|
22 | + * @param string $key |
|
23 | + * @param mixed $content |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function handle($key, $content) |
|
27 | + { |
|
28 | + return $this->render->handle($key, "#!!" . $content->render() . "!!#"); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -6,14 +6,14 @@ |
||
6 | 6 | |
7 | 7 | class Render implements Renderable { |
8 | 8 | |
9 | - /** |
|
10 | - * [handle description] |
|
11 | - * @param string $key |
|
12 | - * @param mixed $content |
|
13 | - * @return array |
|
14 | - */ |
|
15 | - public function handle($key, $content) |
|
16 | - { |
|
17 | - return [$key => $content]; |
|
18 | - } |
|
9 | + /** |
|
10 | + * [handle description] |
|
11 | + * @param string $key |
|
12 | + * @param mixed $content |
|
13 | + * @return array |
|
14 | + */ |
|
15 | + public function handle($key, $content) |
|
16 | + { |
|
17 | + return [$key => $content]; |
|
18 | + } |
|
19 | 19 | } |
@@ -10,19 +10,19 @@ |
||
10 | 10 | * [__construct description] |
11 | 11 | * @param \EnergieProduction\Chart\Contracts\Renderable $render |
12 | 12 | */ |
13 | - public function __construct(Renderable $render) |
|
14 | - { |
|
15 | - $this->render = $render; |
|
16 | - } |
|
13 | + public function __construct(Renderable $render) |
|
14 | + { |
|
15 | + $this->render = $render; |
|
16 | + } |
|
17 | 17 | |
18 | - /** |
|
19 | - * [handle description] |
|
20 | - * @param string $key |
|
21 | - * @param mixed $content |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function handle($key, $content) |
|
25 | - { |
|
26 | - return $this->render->handle($key, $content); |
|
27 | - } |
|
18 | + /** |
|
19 | + * [handle description] |
|
20 | + * @param string $key |
|
21 | + * @param mixed $content |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function handle($key, $content) |
|
25 | + { |
|
26 | + return $this->render->handle($key, $content); |
|
27 | + } |
|
28 | 28 | } |
@@ -8,62 +8,62 @@ |
||
8 | 8 | |
9 | 9 | class Option { |
10 | 10 | |
11 | - protected $options; |
|
11 | + protected $options; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - $this->options = []; |
|
16 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + $this->options = []; |
|
16 | + } |
|
17 | 17 | |
18 | - /** |
|
19 | - * [pushSubset description] |
|
20 | - * @param string $subset |
|
21 | - * @param \closure $closure |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function pushSubset($subset, closure $closure) |
|
25 | - { |
|
26 | - $option = new self; |
|
18 | + /** |
|
19 | + * [pushSubset description] |
|
20 | + * @param string $subset |
|
21 | + * @param \closure $closure |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function pushSubset($subset, closure $closure) |
|
25 | + { |
|
26 | + $option = new self; |
|
27 | 27 | |
28 | - call_user_func($closure, $option); |
|
28 | + call_user_func($closure, $option); |
|
29 | 29 | |
30 | - $render = new Renderable\Render(); |
|
31 | - $render = new Renderable\Subset($render); |
|
30 | + $render = new Renderable\Render(); |
|
31 | + $render = new Renderable\Subset($render); |
|
32 | 32 | |
33 | - $this->options = array_merge($this->options, $render->handle( |
|
34 | - $subset, |
|
35 | - $option->render() |
|
36 | - )); |
|
37 | - } |
|
33 | + $this->options = array_merge($this->options, $render->handle( |
|
34 | + $subset, |
|
35 | + $option->render() |
|
36 | + )); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * [pushCriteria description] |
|
41 | - * @param mixed $criteria |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function pushCriteria($criteria) |
|
45 | - { |
|
46 | - $content = $criteria->getcontent(); |
|
39 | + /** |
|
40 | + * [pushCriteria description] |
|
41 | + * @param mixed $criteria |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function pushCriteria($criteria) |
|
45 | + { |
|
46 | + $content = $criteria->getcontent(); |
|
47 | 47 | |
48 | - $render = new Renderable\Render(); |
|
49 | - $render = new Renderable\Criteria($render); |
|
48 | + $render = new Renderable\Render(); |
|
49 | + $render = new Renderable\Criteria($render); |
|
50 | 50 | |
51 | - if ($content instanceof Expression) { |
|
52 | - $render = new Renderable\Expression($render); |
|
53 | - } |
|
51 | + if ($content instanceof Expression) { |
|
52 | + $render = new Renderable\Expression($render); |
|
53 | + } |
|
54 | 54 | |
55 | - $this->options = array_merge($this->options, $render->handle( |
|
56 | - $criteria->resolveKey(), |
|
57 | - $content |
|
58 | - )); |
|
59 | - } |
|
55 | + $this->options = array_merge($this->options, $render->handle( |
|
56 | + $criteria->resolveKey(), |
|
57 | + $content |
|
58 | + )); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * [render description] |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public function render() |
|
66 | - { |
|
67 | - return $this->options; |
|
68 | - } |
|
61 | + /** |
|
62 | + * [render description] |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public function render() |
|
66 | + { |
|
67 | + return $this->options; |
|
68 | + } |
|
69 | 69 | } |
@@ -7,61 +7,61 @@ |
||
7 | 7 | |
8 | 8 | class Chart { |
9 | 9 | |
10 | - protected $options = []; |
|
10 | + protected $options = []; |
|
11 | 11 | |
12 | - /** |
|
13 | - * [pushSubset description] |
|
14 | - * @param string $subset |
|
15 | - * @param closure $closure |
|
16 | - * @throws EnergieProduction\Chart\Exceptions\DotNotationNotAvailableException |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function pushSubset($subset, closure $closure) |
|
20 | - { |
|
21 | - $option = new Option(); |
|
12 | + /** |
|
13 | + * [pushSubset description] |
|
14 | + * @param string $subset |
|
15 | + * @param closure $closure |
|
16 | + * @throws EnergieProduction\Chart\Exceptions\DotNotationNotAvailableException |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function pushSubset($subset, closure $closure) |
|
20 | + { |
|
21 | + $option = new Option(); |
|
22 | 22 | |
23 | - $option->pushSubset($subset, $closure); |
|
23 | + $option->pushSubset($subset, $closure); |
|
24 | 24 | |
25 | - $render = $option->render(); |
|
25 | + $render = $option->render(); |
|
26 | 26 | |
27 | - if (starts_with($subset, 'series')) { |
|
27 | + if (starts_with($subset, 'series')) { |
|
28 | 28 | |
29 | - if (str_contains($subset, '.')) { |
|
30 | - throw new Exceptions\DotNotationNotAvailableException(); |
|
31 | - } |
|
29 | + if (str_contains($subset, '.')) { |
|
30 | + throw new Exceptions\DotNotationNotAvailableException(); |
|
31 | + } |
|
32 | 32 | |
33 | - $this->options['series'][] = $render['series']; |
|
34 | - } |
|
35 | - else { |
|
36 | - $this->options = array_merge_recursive($this->options, $render); |
|
37 | - } |
|
38 | - } |
|
33 | + $this->options['series'][] = $render['series']; |
|
34 | + } |
|
35 | + else { |
|
36 | + $this->options = array_merge_recursive($this->options, $render); |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * [render description] |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function render() |
|
45 | - { |
|
46 | - $formatedOption = json_encode($this->options); |
|
40 | + /** |
|
41 | + * [render description] |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function render() |
|
45 | + { |
|
46 | + $formatedOption = json_encode($this->options); |
|
47 | 47 | |
48 | - if (str_contains($formatedOption, '"#!!')) { |
|
49 | - $formatedOption = $this->restoreExpressions($formatedOption); |
|
50 | - } |
|
48 | + if (str_contains($formatedOption, '"#!!')) { |
|
49 | + $formatedOption = $this->restoreExpressions($formatedOption); |
|
50 | + } |
|
51 | 51 | |
52 | - return $formatedOption; |
|
53 | - } |
|
52 | + return $formatedOption; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * [restoreExpressions description] |
|
57 | - * @param string $formatedOption |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - protected function restoreExpressions($formatedOption) |
|
61 | - { |
|
62 | - $formatedOption = str_replace('"#!!', '', $formatedOption); |
|
63 | - $formatedOption = str_replace('!!#"', '', $formatedOption); |
|
55 | + /** |
|
56 | + * [restoreExpressions description] |
|
57 | + * @param string $formatedOption |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + protected function restoreExpressions($formatedOption) |
|
61 | + { |
|
62 | + $formatedOption = str_replace('"#!!', '', $formatedOption); |
|
63 | + $formatedOption = str_replace('!!#"', '', $formatedOption); |
|
64 | 64 | |
65 | - return $formatedOption; |
|
66 | - } |
|
65 | + return $formatedOption; |
|
66 | + } |
|
67 | 67 | } |
@@ -31,8 +31,7 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | $this->options['series'][] = $render['series']; |
34 | - } |
|
35 | - else { |
|
34 | + } else { |
|
36 | 35 | $this->options = array_merge_recursive($this->options, $render); |
37 | 36 | } |
38 | 37 | } |