Passed
Push — master ( d46d5f...674e23 )
by Luis
44s queued 12s
created

UseStatement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isAliasedAs() 0 3 2
A endsWith() 0 3 1
A __construct() 0 2 1
A fullyQualifiedName() 0 3 2
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
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 UseStatement
11
{
12
    public function __construct(private Name $name, private ?Name $alias)
13
    {
14
    }
15
16
    public function endsWith(Name $name): bool
17
    {
18
        return str_ends_with(haystack: (string) $this->name, needle: $name->removeArraySuffix());
19
    }
20
21
    public function isAliasedAs(Name $name): bool
22
    {
23
        return $this->alias !== null && (string) $this->alias === $name->removeArraySuffix();
24
    }
25
26
    public function fullyQualifiedName(Name $name): string
27
    {
28
        return $name->isArray() ? $this->name->fullName() . '[]' : $this->name->fullName();
29
    }
30
}
31