Passed
Pull Request — master (#38)
by Marco
02:19
created

OnlyProtectedClassConstantChanged::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\ApiCompare\Comparator\BackwardsCompatibility\ClassConstantBased;
6
7
use Roave\ApiCompare\Changes;
8
use Roave\BetterReflection\Reflection\ReflectionClassConstant;
9
10
final class OnlyProtectedClassConstantChanged implements ClassConstantBased
11
{
12
    /** @var ClassConstantBased */
13
    private $constantCheck;
14
15
    public function __construct(ClassConstantBased $constantCheck)
16
    {
17
        $this->constantCheck = $constantCheck;
18
    }
19
20
    public function compare(ReflectionClassConstant $fromConstant, ReflectionClassConstant $toConstant) : Changes
21
    {
22
        if (! $fromConstant->isProtected()) {
23
            return Changes::new();
24
        }
25
26
        return $this->constantCheck->compare($fromConstant, $toConstant);
27
    }
28
}
29