Passed
Pull Request — master (#38)
by Marco
03:01
created

MultiFunctionBased   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A compare() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\ApiCompare\Comparator\BackwardsCompatibility\FunctionBased;
6
7
use Roave\ApiCompare\Changes;
8
use Roave\BetterReflection\Reflection\ReflectionFunctionAbstract;
9
10
final class MultiFunctionBased implements FunctionBased
11
{
12
    /** @var FunctionBased[] */
13
    private $checks;
14
15
    public function __construct(FunctionBased ...$checks)
16
    {
17
        $this->checks = $checks;
18
    }
19
20
    public function compare(ReflectionFunctionAbstract $fromFunction, ReflectionFunctionAbstract $toClass) : Changes
21
    {
22
        return array_reduce(
23
            $this->checks,
24
            function (Changes $changes, FunctionBased $check) use ($fromFunction, $toClass) : Changes {
25
                return $changes->mergeWith($check->compare($fromFunction, $toClass));
26
            },
27
            Changes::new()
28
        );
29
    }
30
}
31