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

OnlyPublicClassConstantChanged::compare()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
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 OnlyPublicClassConstantChanged implements ClassConstantBased
11
{
12
    /**
13
     * @var ClassConstantBased
14
     */
15
    private $constantCheck;
16
17
    public function __construct(ClassConstantBased $constantCheck)
18
    {
19
        $this->constantCheck = $constantCheck;
20
    }
21
22
    public function compare(ReflectionClassConstant $fromConstant, ReflectionClassConstant $toConstant) : Changes
23
    {
24
        if (! $fromConstant->isPublic()) {
25
            return Changes::new();
26
        }
27
28
        return $this->constantCheck->compare($fromConstant, $toConstant);
29
    }
30
}
31