Completed
Branch EDTR/master (da238f)
by
unknown
09:58 queued 01:23
created

MultiRouteSpecification::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\specifications;
4
5
use EventEspresso\core\exceptions\InvalidEntityException;
6
use EventEspresso\core\services\request\RequestInterface;
7
8
/**
9
 * Class MultiRouteSpecification
10
 * Used for combining multiple Route Match Specifications into a single specification
11
 *
12
 * @package EventEspresso\core\domain\entities\routing
13
 * @author  Brent Christensen
14
 * @since   4.9.71.p
15
 */
16
abstract class MultiRouteSpecification extends RouteMatchSpecification
17
{
18
19
    /**
20
     * @var RouteMatchSpecificationInterface[] $specifications
21
     */
22
    protected $specifications;
23
24
    /**
25
     * MultiRouteSpecification constructor.
26
     *
27
     * @param RouteMatchSpecificationInterface[] $specifications
28
     * @param RequestInterface                   $request
29
     * @throws InvalidEntityException
30
     */
31
    public function __construct(array $specifications, RequestInterface $request)
32
    {
33
        foreach ($specifications as $specification) {
34
            if (! $specification instanceof RouteMatchSpecificationInterface) {
35
                throw new InvalidEntityException(
36
                    $specification,
37
                    'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface'
38
                );
39
            }
40
        }
41
        $this->specifications = $specifications;
42
        parent::__construct($request);
43
    }
44
}
45