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

TraitBecameInterface   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 4
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