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

SkipMethodBasedErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

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