-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetricVolumeUnit.php
More file actions
86 lines (78 loc) · 2.43 KB
/
Copy pathMetricVolumeUnit.php
File metadata and controls
86 lines (78 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
namespace Andante\Measurement\Unit\Volume;
use Andante\Measurement\Contract\DimensionInterface;
use Andante\Measurement\Contract\UnitInterface;
use Andante\Measurement\Dimension\Volume;
use Andante\Measurement\Unit\SymbolNotation;
use Andante\Measurement\Unit\UnitSystem;
/**
* Metric system units of volume.
*
* The SI unit of volume is the cubic meter (m³).
* The liter (L) is a commonly used non-SI metric unit.
* 1 L = 0.001 m³ = 1 dm³
*/
enum MetricVolumeUnit implements UnitInterface
{
case CubicMeter;
case CubicDecimeter;
case CubicCentimeter;
case CubicMillimeter;
case Liter;
case Deciliter;
case Centiliter;
case Milliliter;
case Hectoliter;
case Kiloliter;
public function symbol(SymbolNotation $notation = SymbolNotation::Default): string
{
return match ($this) {
self::CubicMeter => match ($notation) {
SymbolNotation::ASCII => 'm3',
default => 'm³',
},
self::CubicDecimeter => match ($notation) {
SymbolNotation::ASCII => 'dm3',
default => 'dm³',
},
self::CubicCentimeter => match ($notation) {
SymbolNotation::ASCII => 'cm3',
default => 'cm³',
},
self::CubicMillimeter => match ($notation) {
SymbolNotation::ASCII => 'mm3',
default => 'mm³',
},
self::Liter => 'L',
self::Deciliter => 'dL',
self::Centiliter => 'cL',
self::Milliliter => 'mL',
self::Hectoliter => 'hL',
self::Kiloliter => 'kL',
};
}
public function name(): string
{
return match ($this) {
self::CubicMeter => 'cubic meter',
self::CubicDecimeter => 'cubic decimeter',
self::CubicCentimeter => 'cubic centimeter',
self::CubicMillimeter => 'cubic millimeter',
self::Liter => 'liter',
self::Deciliter => 'deciliter',
self::Centiliter => 'centiliter',
self::Milliliter => 'milliliter',
self::Hectoliter => 'hectoliter',
self::Kiloliter => 'kiloliter',
};
}
public function dimension(): DimensionInterface
{
return Volume::instance();
}
public function system(): UnitSystem
{
return UnitSystem::Metric;
}
}