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

TraitBecameInterface::__invoke()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 5
nc 2
nop 2
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\TraitBased;
6
7
use Roave\BackwardCompatibility\Change;
8
use Roave\BackwardCompatibility\Changes;
9
use Roave\BetterReflection\Reflection\ReflectionClass;
10
use function sprintf;
11
12
/**
13
 * A trait cannot change to become a interface, as that forces all implementations
14
 * that use it to change from `use` to `implements`
15
 */
16
final class TraitBecameInterface implements TraitBased
17
{
18
    public function __invoke(ReflectionClass $fromTrait, ReflectionClass $toTrait) : Changes
19
    {
20
        if ($toTrait->isTrait() || ! $toTrait->isInterface() || ! $fromTrait->isTrait()) {
21
            return Changes::empty();
22
        }
23
24
        return Changes::fromList(Change::changed(
25
            sprintf('Interface %s became an interface', $fromTrait->getName()),
26
            true
27
        ));
28
    }
29
}
30