Code Duplication    Length = 29-29 lines in 3 locations

src/AnyOfSpecification.php 1 location

@@ 5-33 (lines=29) @@
2
3
namespace Tanigami\Specification;
4
5
class AnyOfSpecification extends Specification
6
{
7
    /**
8
     * @var Specification[]
9
     */
10
    private $specifications;
11
12
    /**
13
     * @param Specification[] ...$specifications
14
     */
15
    public function __construct(Specification ...$specifications)
16
    {
17
        $this->specifications = $specifications;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function isSatisfiedBy($object): bool
24
    {
25
        foreach ($this->specifications as $specification) {
26
            if (!$specification->isSatisfiedBy($object)) {
27
                return false;
28
            }
29
        }
30
31
        return true;
32
    }
33
}

src/NoneOfSpecification.php 1 location

@@ 5-33 (lines=29) @@
2
3
namespace Tanigami\Specification;
4
5
class NoneOfSpecification extends Specification
6
{
7
    /**
8
     * @var Specification[]
9
     */
10
    private $specifications;
11
12
    /**
13
     * @param Specification[] ...$specifications
14
     */
15
    public function __construct(Specification ...$specifications)
16
    {
17
        $this->specifications = $specifications;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function isSatisfiedBy($object): bool
24
    {
25
        foreach ($this->specifications as $specification) {
26
            if ($specification->isSatisfiedBy($object)) {
27
                return false;
28
            }
29
        }
30
31
        return true;
32
    }
33
}
34

src/OneOfSpecification.php 1 location

@@ 5-33 (lines=29) @@
2
3
namespace Tanigami\Specification;
4
5
class OneOfSpecification extends Specification
6
{
7
    /**
8
     * @var Specification[]
9
     */
10
    private $specifications;
11
12
    /**
13
     * @param Specification[] ...$specifications
14
     */
15
    public function __construct(Specification ...$specifications)
16
    {
17
        $this->specifications = $specifications;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function isSatisfiedBy($object): bool
24
    {
25
        foreach ($this->specifications as $specification) {
26
            if ($specification->isSatisfiedBy($object)) {
27
                return true;
28
            }
29
        }
30
31
        return false;
32
    }
33
}
34