Disjunction::getTerms()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the tmilos/scim-filter-parser package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\ScimFilterParser\Ast;
13
14 View Code Duplication
class Disjunction extends Filter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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