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

AnyOf   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A isSatisfiedBy() 0 10 3
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