Passed
Pull Request — master (#50)
by Marco
02:46
created

MultipleChecksOnAMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased;
6
7
use Roave\BackwardCompatibility\Changes;
8
use Roave\BetterReflection\Reflection\ReflectionMethod;
9
use function array_reduce;
10
11
final class MultipleChecksOnAMethod implements MethodBased
12
{
13
    /** @var MethodBased[] */
14
    private $checks;
15
16
    public function __construct(MethodBased ...$checks)
17
    {
18
        $this->checks = $checks;
19
    }
20
21
    public function __invoke(ReflectionMethod $fromMethod, ReflectionMethod $toMethod) : Changes
22
    {
23
        return array_reduce(
24
            $this->checks,
25
            function (Changes $changes, MethodBased $check) use ($fromMethod, $toMethod) : Changes {
26
                return $changes->mergeWith($check->__invoke($fromMethod, $toMethod));
27
            },
28
            Changes::empty()
29
        );
30
    }
31
}
32