Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

UseStatements   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 6
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code;
9
10
final class UseStatements
11
{
12
    /** @param UseStatement[] $useStatements */
13 85
    public function __construct(private readonly array $useStatements)
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_ARRAY, expecting T_VARIABLE on line 13 at column 49
Loading history...
14
    {
15
    }
16
17 47
    public function fullyQualifiedNameFor(Name $name): string
18
    {
19 47
        foreach ($this->useStatements as $useStatement) {
20 29
            if ($useStatement->endsWith($name)) {
21 25
                return $useStatement->fullyQualifiedName($name);
22
            }
23 24
            if ($useStatement->includes($name)) {
24 2
                return $useStatement->merge($name);
25
            }
26 22
            if ($useStatement->isAliasedAs($name)) {
27 8
                return $useStatement->fullyQualifiedName($name);
28
            }
29
        }
30 35
        return $name->fullName();
31
    }
32
}
33