InlineFqnWithinSameNamespaceProcessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 17
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldProcess() 0 4 1
A process() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jerowork\ClassDependenciesParser\PhpParser\NodeVisitor\InlineFqnParser\Processor;
6
7
use Jerowork\ClassDependenciesParser\Fqn;
8
use Jerowork\ClassDependenciesParser\ClassDependencies;
9
use PhpParser\Node;
10
use PhpParser\Node\Name;
11
12
final class InlineFqnWithinSameNamespaceProcessor implements InlineFqnProcessor
13
{
14 4
    public function shouldProcess(Node $parent, Name $name, ClassDependencies $classDependencies): bool
15
    {
16
        // Fallback processor, needs to be processed as last
17 4
        return true;
18
    }
19
20 4
    public function process(Node $parent, Name $name, ClassDependencies $classDependencies): ?Fqn
21
    {
22 4
        $classFqn = $classDependencies->getFqn();
23
24 4
        if ($classFqn === null) {
25
            return null;
26
        }
27
28 4
        return new Fqn(sprintf('%s\%s', $classFqn->getFullFqnWithoutLastPart(), $name));
29
    }
30
}
31