@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Render { |
| 6 | 6 | |
| 7 | - public function handle($key, $content) |
|
| 8 | - { |
|
| 9 | - return [$key => $content]; |
|
| 10 | - } |
|
| 7 | + public function handle($key, $content) |
|
| 8 | + { |
|
| 9 | + return [$key => $content]; |
|
| 10 | + } |
|
| 11 | 11 | } |
@@ -4,13 +4,13 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Criteria { |
| 6 | 6 | |
| 7 | - public function __construct($render) |
|
| 8 | - { |
|
| 9 | - $this->render = $render; |
|
| 10 | - } |
|
| 7 | + public function __construct($render) |
|
| 8 | + { |
|
| 9 | + $this->render = $render; |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function handle($key, $content) |
|
| 13 | - { |
|
| 14 | - return $this->render->handle($key, $content); |
|
| 15 | - } |
|
| 12 | + public function handle($key, $content) |
|
| 13 | + { |
|
| 14 | + return $this->render->handle($key, $content); |
|
| 15 | + } |
|
| 16 | 16 | } |
@@ -4,38 +4,38 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Subset { |
| 6 | 6 | |
| 7 | - public function __construct($render) |
|
| 8 | - { |
|
| 9 | - $this->render = $render; |
|
| 10 | - } |
|
| 7 | + public function __construct($render) |
|
| 8 | + { |
|
| 9 | + $this->render = $render; |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function handle($key, $content) |
|
| 13 | - { |
|
| 14 | - if (str_contains($key, '.')) { |
|
| 12 | + public function handle($key, $content) |
|
| 13 | + { |
|
| 14 | + if (str_contains($key, '.')) { |
|
| 15 | 15 | |
| 16 | - $path = explode('.', $key); |
|
| 16 | + $path = explode('.', $key); |
|
| 17 | 17 | |
| 18 | - $result = []; |
|
| 18 | + $result = []; |
|
| 19 | 19 | |
| 20 | - $this->dotNotationToArray($result, $path, $content); |
|
| 20 | + $this->dotNotationToArray($result, $path, $content); |
|
| 21 | 21 | |
| 22 | - return $this->render->handle($path[0], $result); |
|
| 23 | - } |
|
| 22 | + return $this->render->handle($path[0], $result); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - return $this->render->handle($key, $content); |
|
| 26 | - } |
|
| 25 | + return $this->render->handle($key, $content); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - protected function dotNotationToArray(array &$arr, $path, $val) |
|
| 29 | - { |
|
| 30 | - $loc = &$arr; |
|
| 28 | + protected function dotNotationToArray(array &$arr, $path, $val) |
|
| 29 | + { |
|
| 30 | + $loc = &$arr; |
|
| 31 | 31 | |
| 32 | - array_shift($path); |
|
| 32 | + array_shift($path); |
|
| 33 | 33 | |
| 34 | - foreach($path as $step) |
|
| 35 | - { |
|
| 36 | - $loc = &$loc[$step]; |
|
| 37 | - } |
|
| 34 | + foreach($path as $step) |
|
| 35 | + { |
|
| 36 | + $loc = &$loc[$step]; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return $loc = $val; |
|
| 40 | - } |
|
| 39 | + return $loc = $val; |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -6,32 +6,32 @@ |
||
| 6 | 6 | |
| 7 | 7 | abstract class Builder implements Criteria { |
| 8 | 8 | |
| 9 | - protected $content; |
|
| 10 | - |
|
| 11 | - public function __construct($content) |
|
| 12 | - { |
|
| 13 | - $this->content = $content; |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public function getKey() |
|
| 17 | - { |
|
| 18 | - if (isset($this->key)) { |
|
| 19 | - return $this->key; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - return lcfirst(class_basename(get_class($this))); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function getContent() |
|
| 26 | - { |
|
| 27 | - return $this->content; |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function render() |
|
| 31 | - { |
|
| 32 | - $render = new Renderable\Render(); |
|
| 33 | - $render = new Renderable\Criteria($render); |
|
| 34 | - |
|
| 35 | - return $render->handle($this->getKey(), $content); |
|
| 36 | - } |
|
| 9 | + protected $content; |
|
| 10 | + |
|
| 11 | + public function __construct($content) |
|
| 12 | + { |
|
| 13 | + $this->content = $content; |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + public function getKey() |
|
| 17 | + { |
|
| 18 | + if (isset($this->key)) { |
|
| 19 | + return $this->key; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + return lcfirst(class_basename(get_class($this))); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function getContent() |
|
| 26 | + { |
|
| 27 | + return $this->content; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function render() |
|
| 31 | + { |
|
| 32 | + $render = new Renderable\Render(); |
|
| 33 | + $render = new Renderable\Criteria($render); |
|
| 34 | + |
|
| 35 | + return $render->handle($this->getKey(), $content); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -6,19 +6,19 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Chart { |
| 8 | 8 | |
| 9 | - protected $options = []; |
|
| 9 | + protected $options = []; |
|
| 10 | 10 | |
| 11 | - public function pushSubset($subset, closure $closure) |
|
| 12 | - { |
|
| 13 | - $option = new Option(); |
|
| 11 | + public function pushSubset($subset, closure $closure) |
|
| 12 | + { |
|
| 13 | + $option = new Option(); |
|
| 14 | 14 | |
| 15 | - $option->pushSubset($subset, $closure); |
|
| 15 | + $option->pushSubset($subset, $closure); |
|
| 16 | 16 | |
| 17 | - $this->options[] = $option->render(); |
|
| 18 | - } |
|
| 17 | + $this->options[] = $option->render(); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function render() |
|
| 21 | - { |
|
| 22 | - return json_encode($this->options); |
|
| 23 | - } |
|
| 20 | + public function render() |
|
| 21 | + { |
|
| 22 | + return json_encode($this->options); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -8,41 +8,41 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Option { |
| 10 | 10 | |
| 11 | - protected $options; |
|
| 12 | - |
|
| 13 | - public function __construct() |
|
| 14 | - { |
|
| 15 | - $this->options = []; |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public function pushCriteria(Criteria $criteria) |
|
| 19 | - { |
|
| 20 | - $render = new Renderable\Render(); |
|
| 21 | - $render = new Renderable\Criteria($render); |
|
| 22 | - |
|
| 23 | - $this->options = array_merge($this->options, $render->handle( |
|
| 24 | - $criteria->getKey(), |
|
| 25 | - $criteria->getcontent() |
|
| 26 | - )); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function pushSubset($subset, closure $closure) |
|
| 30 | - { |
|
| 31 | - $option = new self; |
|
| 32 | - |
|
| 33 | - call_user_func($closure, $option); |
|
| 34 | - |
|
| 35 | - $render = new Renderable\Render(); |
|
| 36 | - $render = new Renderable\Subset($render); |
|
| 37 | - |
|
| 38 | - $this->options = array_merge($this->options, $render->handle( |
|
| 39 | - $subset, |
|
| 40 | - $option->render() |
|
| 41 | - )); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function render() |
|
| 45 | - { |
|
| 46 | - return $this->options; |
|
| 47 | - } |
|
| 11 | + protected $options; |
|
| 12 | + |
|
| 13 | + public function __construct() |
|
| 14 | + { |
|
| 15 | + $this->options = []; |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public function pushCriteria(Criteria $criteria) |
|
| 19 | + { |
|
| 20 | + $render = new Renderable\Render(); |
|
| 21 | + $render = new Renderable\Criteria($render); |
|
| 22 | + |
|
| 23 | + $this->options = array_merge($this->options, $render->handle( |
|
| 24 | + $criteria->getKey(), |
|
| 25 | + $criteria->getcontent() |
|
| 26 | + )); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function pushSubset($subset, closure $closure) |
|
| 30 | + { |
|
| 31 | + $option = new self; |
|
| 32 | + |
|
| 33 | + call_user_func($closure, $option); |
|
| 34 | + |
|
| 35 | + $render = new Renderable\Render(); |
|
| 36 | + $render = new Renderable\Subset($render); |
|
| 37 | + |
|
| 38 | + $this->options = array_merge($this->options, $render->handle( |
|
| 39 | + $subset, |
|
| 40 | + $option->render() |
|
| 41 | + )); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function render() |
|
| 45 | + { |
|
| 46 | + return $this->options; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ChartServiceProvider extends ServiceProvider{ |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Indicates if loading of the provider is deferred. |
|
| 12 | - * |
|
| 13 | - * @var bool |
|
| 14 | - */ |
|
| 15 | - protected $defer = false; |
|
| 16 | - |
|
| 17 | - public function boot() |
|
| 18 | - { |
|
| 19 | - // |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function register() |
|
| 23 | - { |
|
| 24 | - $this->app->bind('chart', function($app) { |
|
| 25 | - return new Chart(); |
|
| 26 | - }); |
|
| 27 | - } |
|
| 10 | + /** |
|
| 11 | + * Indicates if loading of the provider is deferred. |
|
| 12 | + * |
|
| 13 | + * @var bool |
|
| 14 | + */ |
|
| 15 | + protected $defer = false; |
|
| 16 | + |
|
| 17 | + public function boot() |
|
| 18 | + { |
|
| 19 | + // |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function register() |
|
| 23 | + { |
|
| 24 | + $this->app->bind('chart', function($app) { |
|
| 25 | + return new Chart(); |
|
| 26 | + }); |
|
| 27 | + } |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
@@ -4,41 +4,41 @@ |
||
| 4 | 4 | |
| 5 | 5 | class List { |
| 6 | 6 | |
| 7 | - protected $list; |
|
| 8 | - |
|
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->list = []; |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - public function set($key, $values) |
|
| 15 | - { |
|
| 16 | - $this->list[$key] = $values; |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - public function setDotNotation($dotNotations, $values) |
|
| 20 | - { |
|
| 21 | - $render = []; |
|
| 22 | - $this->dotNotationToArray($render, $dotNotations, $values); |
|
| 23 | - $this->list = array_merge_recursive($this->list, $render); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function render() |
|
| 27 | - { |
|
| 28 | - return $this->list; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - protected function dotNotationToArray(array &$arr, $path, $val) |
|
| 32 | - { |
|
| 33 | - $loc = &$arr; |
|
| 34 | - |
|
| 35 | - $path = explode('.', $path); |
|
| 36 | - |
|
| 37 | - foreach($path as $step) |
|
| 38 | - { |
|
| 39 | - $loc = &$loc[$step]; |
|
| 40 | - } |
|
| 7 | + protected $list; |
|
| 8 | + |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->list = []; |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + public function set($key, $values) |
|
| 15 | + { |
|
| 16 | + $this->list[$key] = $values; |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + public function setDotNotation($dotNotations, $values) |
|
| 20 | + { |
|
| 21 | + $render = []; |
|
| 22 | + $this->dotNotationToArray($render, $dotNotations, $values); |
|
| 23 | + $this->list = array_merge_recursive($this->list, $render); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function render() |
|
| 27 | + { |
|
| 28 | + return $this->list; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + protected function dotNotationToArray(array &$arr, $path, $val) |
|
| 32 | + { |
|
| 33 | + $loc = &$arr; |
|
| 34 | + |
|
| 35 | + $path = explode('.', $path); |
|
| 36 | + |
|
| 37 | + foreach($path as $step) |
|
| 38 | + { |
|
| 39 | + $loc = &$loc[$step]; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $loc = $val; |
|
| 43 | - } |
|
| 42 | + return $loc = $val; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |