Passed
Push — feature/allow-optional-project... ( 5c3cfb )
by Chema
04:42
created

buildClassCandidate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0932

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
ccs 5
cts 7
cp 0.7143
rs 9.9332
cc 2
nc 2
nop 3
crap 2.0932
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 31
    public function buildClassCandidate(string $projectNamespace, string $resolvableType, ClassInfo $classInfo): string
12
    {
13 31
        if ($projectNamespace !== '') {
14 31
            return sprintf(
15
                '\\%s\\%s\\%s',
16 31
                trim($projectNamespace, '\\'),
17 31
                $classInfo->getModuleName(),
18
                $resolvableType
19
            );
20
        }
21
22
        return sprintf(
23
            '\\%s\\%s',
24
            $classInfo->getModuleName(),
25
            $resolvableType
26
        );
27
    }
28
}
29