Completed
Push — master ( a75674...55081d )
by
unknown
06:34
created

Option::pushSubset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
3
namespace EnergieProduction\Chart;
4
5
use closure;
6
use EnergieProduction\Chart\Renderable;
7
use EnergieProduction\Chart\Contracts\Criteria;
8
9
class Option {
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
    }
48
}
49