Code Duplication    Length = 48-48 lines in 2 locations

src/Ast/Conjunction.php 1 location

@@ 14-61 (lines=48) @@
11
12
namespace Tmilos\ScimFilterParser\Ast;
13
14
class Conjunction extends Term
15
{
16
    /** @var Filter[] */
17
    private $factors = [];
18
19
    /**
20
     * @param Filter[] $factors
21
     */
22
    public function __construct(array $factors = [])
23
    {
24
        foreach ($factors as $factor) {
25
            $this->add($factor);
26
        }
27
    }
28
29
    /**
30
     * @param Filter $factor
31
     */
32
    public function add(Filter $factor)
33
    {
34
        $this->factors[] = $factor;
35
    }
36
37
    /**
38
     * @return Filter[]
39
     */
40
    public function getFactors()
41
    {
42
        return $this->factors;
43
    }
44
45
    public function dump()
46
    {
47
        $arr = [];
48
        foreach ($this->factors as $factor) {
49
            $arr[] = $factor->dump();
50
        }
51
52
        return [
53
            'Conjunction' => $arr,
54
        ];
55
    }
56
57
    public function __toString()
58
    {
59
        return implode(' and ', $this->factors);
60
    }
61
}
62

src/Ast/Disjunction.php 1 location

@@ 14-61 (lines=48) @@
11
12
namespace Tmilos\ScimFilterParser\Ast;
13
14
class Disjunction extends Filter
15
{
16
    /** @var Term[] */
17
    private $terms = [];
18
19
    /**
20
     * @param Term[] $terms
21
     */
22
    public function __construct(array $terms = [])
23
    {
24
        foreach ($terms as $term) {
25
            $this->add($term);
26
        }
27
    }
28
29
    /**
30
     * @param Term $term
31
     */
32
    public function add(Term $term)
33
    {
34
        $this->terms[] = $term;
35
    }
36
37
    /**
38
     * @return Term[]
39
     */
40
    public function getTerms()
41
    {
42
        return $this->terms;
43
    }
44
45
    public function __toString()
46
    {
47
        return implode(' or ', $this->terms);
48
    }
49
50
    public function dump()
51
    {
52
        $arr = [];
53
        foreach ($this->terms as $term) {
54
            $arr[] = $term->dump();
55
        }
56
57
        return [
58
            'Disjunction' => $arr,
59
        ];
60
    }
61
}
62