Passed
Push — feature/allow-optional-project... ( 5c3cfb...144e57 )
by Chema
03:38
created

buildClassCandidate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
rs 9.9332
ccs 7
cts 7
cp 1
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\ClassNameFinder\Rule;
6
7
use Gacela\Framework\ClassResolver\ClassInfo;
8
9
final class FinderRuleWithoutModulePrefix implements FinderRuleInterface
10
{
11 32
    public function buildClassCandidate(string $projectNamespace, string $resolvableType, ClassInfo $classInfo): string
12
    {
13 32
        if ($projectNamespace !== '') {
14 31
            return sprintf(
15
                '\\%s\\%s\\%s',
16 31
                trim($projectNamespace, '\\'),
17 31
                $classInfo->getModuleName(),
18
                $resolvableType
19
            );
20
        }
21
22 1
        return sprintf(
23
            '\\%s\\%s',
24 1
            $classInfo->getModuleName(),
25
            $resolvableType
26
        );
27
    }
28
}
29