MethodConcretenessChanged   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased;
6
7
use Roave\BackwardCompatibility\Change;
8
use Roave\BackwardCompatibility\Changes;
9
use Roave\BetterReflection\Reflection\ReflectionMethod;
10
use function Safe\sprintf;
11
12
/**
13
 * A method that changes from concrete to abstract forces all child class
14
 * implementations to implement it, and is therefore a BC break
15
 */
16
final class MethodConcretenessChanged implements MethodBased
17
{
18
    public function __invoke(ReflectionMethod $fromMethod, ReflectionMethod $toMethod) : Changes
19
    {
20
        if ($fromMethod->isAbstract() || ! $toMethod->isAbstract()) {
21
            return Changes::empty();
22
        }
23
24
        return Changes::fromList(Change::changed(
25
            sprintf(
26
                'Method %s() of class %s changed from concrete to abstract',
27
                $fromMethod->getName(),
28
                $fromMethod->getDeclaringClass()->getName()
29
            ),
30
            true
31
        ));
32
    }
33
}
34