Passed
Pull Request — master (#108)
by Marco
02:35
created

MultipleChecksOnAFunction::multipleChecks()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased;
6
7
use Roave\BackwardCompatibility\Change;
8
use Roave\BackwardCompatibility\Changes;
9
use Roave\BetterReflection\Reflection\ReflectionFunctionAbstract;
10
11
final class MultipleChecksOnAFunction implements FunctionBased
12
{
13
    /** @var FunctionBased[] */
14
    private $checks;
15
16
    public function __construct(FunctionBased ...$checks)
17
    {
18
        $this->checks = $checks;
19
    }
20
21
    public function __invoke(ReflectionFunctionAbstract $fromFunction, ReflectionFunctionAbstract $toFunction) : Changes
22
    {
23
        return Changes::fromIterator($this->multipleChecks($fromFunction, $toFunction));
24
    }
25
26
    /** @return iterable|Change[] */
27
    private function multipleChecks(ReflectionFunctionAbstract $fromFunction, ReflectionFunctionAbstract $toFunction) : iterable
28
    {
29
        foreach ($this->checks as $check) {
30
            yield from $check->__invoke($fromFunction, $toFunction);
0 ignored issues
show
Bug Best Practice introduced by
The expression YieldFromNode returns the type Generator which is incompatible with the documented return type iterable|Roave\BackwardCompatibility\Change[].
Loading history...
31
        }
32
    }
33
}
34