-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImperialAreaUnit.php
More file actions
69 lines (61 loc) · 1.81 KB
/
ImperialAreaUnit.php
File metadata and controls
69 lines (61 loc) · 1.81 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
<?php
declare(strict_types=1);
namespace Andante\Measurement\Unit\Area;
use Andante\Measurement\Contract\DimensionInterface;
use Andante\Measurement\Contract\UnitInterface;
use Andante\Measurement\Dimension\Area;
use Andante\Measurement\Unit\SymbolNotation;
use Andante\Measurement\Unit\UnitSystem;
/**
* Imperial/US customary units of area.
*
* These units are commonly used in the United States and United Kingdom.
*/
enum ImperialAreaUnit implements UnitInterface
{
case SquareFoot;
case SquareInch;
case SquareYard;
case SquareMile;
case Acre;
public function symbol(SymbolNotation $notation = SymbolNotation::Default): string
{
return match ($this) {
self::SquareFoot => match ($notation) {
SymbolNotation::ASCII => 'ft2',
default => 'ft²',
},
self::SquareInch => match ($notation) {
SymbolNotation::ASCII => 'in2',
default => 'in²',
},
self::SquareYard => match ($notation) {
SymbolNotation::ASCII => 'yd2',
default => 'yd²',
},
self::SquareMile => match ($notation) {
SymbolNotation::ASCII => 'mi2',
default => 'mi²',
},
self::Acre => 'ac',
};
}
public function name(): string
{
return match ($this) {
self::SquareFoot => 'square foot',
self::SquareInch => 'square inch',
self::SquareYard => 'square yard',
self::SquareMile => 'square mile',
self::Acre => 'acre',
};
}
public function dimension(): DimensionInterface
{
return Area::instance();
}
public function system(): UnitSystem
{
return UnitSystem::Imperial;
}
}