Completed
Push — master ( 3624c1...ced84f )
by
unknown
01:33
created

Builder   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 37
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A pushCriteria() 0 4 1
B render() 0 16 5
A setCascade() 0 4 1
1
<?php
2
3
namespace EnergieProduction\Chart\Subsets;
4
5
use EnergieProduction\Chart\Criterias\Criteria;
6
7
abstract class Builder implements Subset {
8
9
	protected $criteriaList;
10
	public $cascade = null;
11
12
	public function __construct()
13
	{
14
		$this->criteriaList = collect();
15
	}
16
17
	public function pushCriteria(Criteria $criteria)
18
	{
19
		$this->criteriaList->push($criteria);
20
	}
21
22
	public function render()
23
	{
24
		$formatedSubset = [];
25
26
		foreach ($this->criteriaList as $criteria) {
27
			$formatedSubset = array_merge($formatedSubset, $criteria->render());
28
		}
29
30
		$subset = lcfirst(class_basename(get_class($this)));
31
32
		if ($subset === 'series' && (! $this->cascade || starts_with($this->cascade, 'series.'))) {
33
			return [$subset => [$formatedSubset]];
34
		}
35
36
		return [$subset => $formatedSubset];
37
	}
38
39
	public function setCascade($cascade)
40
	{
41
		$this->cascade = $cascade;
42
	}
43
}
44
45
46