Passed
Push — 6.0 ( 4ac4e1...87e1d7 )
by Olivier
01:56
created

Unit   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 8
dl 0
loc 44
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A get_narrow_name() 0 3 1
A get_name() 0 3 1
A name_for() 0 3 1
A get_short_name() 0 3 1
A get_long_name() 0 3 1
A __construct() 0 4 1
A __toString() 0 3 1
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