Conjunction::getFactors()   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 Conjunction extends Term
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 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