Completed
Pull Request — master (#143)
by Kristof
09:50 queued 04:32
created

AnyOf::isSatisfiedBy()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
/**
3
 * @file
4
 */
5
6
namespace CultuurNet\UDB3\EventHandling\DomainMessage;
7
8
use Broadway\Domain\DomainMessage;
9
10
class AnyOf implements SpecificationInterface
11
{
12
    /**
13
     * @var SpecificationInterface[]
14
     */
15
    private $specifications;
16
17
    public function __construct()
18
    {
19
        $specifications = func_get_args();
20
21
        foreach ($specifications as $specification) {
22
            if (!$specification instanceof SpecificationInterface) {
23
                throw new \InvalidArgumentException('Argument should implement '  . SpecificationInterface::class);
24
            }
25
        }
26
27
        $this->specifications = $specifications;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function isSatisfiedBy(DomainMessage $domainMessage)
34
    {
35
        foreach ($this->specifications as $specification) {
36
            if ($specification->isSatisfiedBy($domainMessage)) {
37
                return true;
38
            }
39
        }
40
41
        return false;
42
    }
43
}
44