Completed
Push — master ( ca1131...42ef77 )
by Woody
03:33
created

MiddlewareSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
rs 10
ccs 8
cts 8
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertValid() 0 12 4
1
<?php
2
3
namespace Equip\Middleware;
4
5
use DomainException;
6
use Equip\Compatibility\StructureWithDataAlias;
7
use Equip\Structure\Set;
8
9
class MiddlewareSet extends Set
10
{
11
    use StructureWithDataAlias;
12
13
    /**
14
     * @inheritDoc
15
     *
16
     * @throws \DomainException if $middlewares does not conform to type expectations
17
     */
18 10
    protected function assertValid(array $middlewares)
19
    {
20 10
        parent::assertValid($middlewares);
21
22 10
        foreach ($middlewares as $middleware) {
23 3
            if (!(is_callable($middleware) || method_exists($middleware, '__invoke'))) {
24 1
                throw new DomainException(
25
                    'All elements of $middlewares must be callable'
26 1
                );
27
            }
28 9
        }
29 9
    }
30
}
31