Completed
Push — master ( 4677f1...4b9138 )
by James
13s queued 10s
created

MultipleChecksOnAClassConstant::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassConstantBased;
6
7
use Roave\BackwardCompatibility\Changes;
8
use Roave\BetterReflection\Reflection\ReflectionClassConstant;
9
use function array_reduce;
10
11
final class MultipleChecksOnAClassConstant implements ClassConstantBased
12
{
13
    /** @var ClassConstantBased[] */
14
    private $checks;
15
16
    public function __construct(ClassConstantBased ...$checks)
17
    {
18
        $this->checks = $checks;
19
    }
20
21
    public function __invoke(ReflectionClassConstant $fromConstant, ReflectionClassConstant $toConstant) : Changes
22
    {
23
        return array_reduce(
24
            $this->checks,
25
            function (Changes $changes, ClassConstantBased $check) use ($fromConstant, $toConstant) : Changes {
26
                return $changes->mergeWith($check->__invoke($fromConstant, $toConstant));
27
            },
28
            Changes::empty()
29
        );
30
    }
31
}
32