Completed
Push — master ( bcba8d...db88fb )
by
unknown
02:22
created

Builder::pushCriteria()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Service\Subsets;
4
5
use Service\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();
0 ignored issues
show
Documentation Bug introduced by
It seems like collect() of type object<Illuminate\Support\Collection> is incompatible with the declared type array of property $criteriaList.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
15
	}
16
17
	public function pushCriteria(Criteria $criteria)
18
	{
19
		$this->criteriaList->push($criteria);
0 ignored issues
show
Bug introduced by
The method push cannot be called on $this->criteriaList (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
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