createInlineFqnBasedOnImportedFqn()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 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\ImportedFqn;
9
use PhpParser\Node\Name;
10
11
trait CreateInlineFqnBasedOnImportedFqnTrait
12
{
13 4
    public function createInlineFqnBasedOnImportedFqn(ImportedFqn $importedFqn, Name $name): ?Fqn
14
    {
15 4
        if (count($name->parts) === 1) {
16 4
            return null;
17
        }
18
19
        // Set importedFqn as non-class (folder namespace)
20 1
        $importedFqn->isNotClass();
21
22 1
        $nameParts = $name->parts;
23 1
        array_shift($nameParts);
24
25 1
        return new Fqn(sprintf('%s\%s', $importedFqn->fqn, implode('\\', $nameParts)));
26
    }
27
}
28