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
|
|||
30 | { |
||
31 | return $this->long_name; |
||
32 | } |
||
33 | |||
34 | private function get_long_name(): string |
||
0 ignored issues
–
show
|
|||
35 | { |
||
36 | return $this->name_for(UnitLength::LONG); |
||
37 | } |
||
38 | |||
39 | private function get_short_name(): string |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | return $this->name_for(UnitLength::SHORT); |
||
42 | } |
||
43 | |||
44 | private function get_narrow_name(): string |
||
0 ignored issues
–
show
|
|||
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 |
This check looks for private methods that have been defined, but are not used inside the class.