Completed
Pull Request — master (#38)
by Marco
02:27
created

AccessibleMethodFunctionBasedChange   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A compare() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased;
6
7
use Roave\ApiCompare\Changes;
8
use Roave\ApiCompare\Comparator\BackwardsCompatibility\FunctionBased\FunctionBased;
9
use Roave\BetterReflection\Reflection\ReflectionMethod;
10
11
/**
12
 * Performs a function BC compliance check on methods that are visible
13
 */
14
final class AccessibleMethodFunctionBasedChange implements MethodBased
15
{
16
    /** @var FunctionBased */
17
    private $functionCheck;
18
19
    public function __construct(FunctionBased $functionCheck)
20
    {
21
        $this->functionCheck = $functionCheck;
22
    }
23
24
    public function compare(ReflectionMethod $fromMethod, ReflectionMethod $toMethod) : Changes
25
    {
26
        if ($fromMethod->isPrivate()) {
27
            return Changes::new();
28
        }
29
30
        return $this->functionCheck->compare($fromMethod, $toMethod);
31
    }
32
}
33