Unit::get_narrow_name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ICanBoogie\CLDR\Supplemental\Units;
4
5
use ICanBoogie\Accessor\AccessorTrait;
6
7
/**
8
 * Representation of a unit.
9
 *
10
 * @property-read string $name
11
 * @uses self::get_name()
12
 * @property-read string $long_name
13
 * @uses self::get_long_name()
14
 * @property-read string $short_name
15
 * @uses self::get_short_name()
16
 * @property-read string $narrow_name
17
 * @uses self::get_narrow_name()
18
 */
19
final class Unit
20
{
21
    /**
22
     * @uses get_name
23
     * @uses get_long_name
24
     * @uses get_short_name
25
     * @uses get_narrow_name
26
     */
27
    use AccessorTrait;
28
29
    private function get_name(): string
0 ignored issues
show
Unused Code introduced by
The method get_name() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
30
    {
31
        return $this->long_name;
32
    }
33
34
    private function get_long_name(): string
0 ignored issues
show
Unused Code introduced by
The method get_long_name() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
35
    {
36
        return $this->name_for(UnitLength::LONG);
37
    }
38
39
    private function get_short_name(): string
0 ignored issues
show
Unused Code introduced by
The method get_short_name() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
40
    {
41
        return $this->name_for(UnitLength::SHORT);
42
    }
43
44
    private function get_narrow_name(): string
0 ignored issues
show
Unused Code introduced by
The method get_narrow_name() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
45
    {
46
        return $this->name_for(UnitLength::NARROW);
47
    }
48
49
    public function __construct(
50
        private readonly Units $units,
51
        private readonly string $unit
52
    ) {
53
    }
54
55
    public function __toString(): string
56
    {
57
        return $this->unit;
58
    }
59
60
    private function name_for(UnitLength $length): string
61
    {
62
        return $this->units->name_for($this->unit, $length);
63
    }
64
}
65