1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PWWEB\Localisation\Enums\Tax; |
4
|
|
|
|
5
|
|
|
use Spatie\Enum\Enum; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* PWWEB\Localisation\Enums\Tax\Type Enum. |
9
|
|
|
* |
10
|
|
|
* Standard Tax Type Enum. |
11
|
|
|
* |
12
|
|
|
* @author Frank Pillukeit <[email protected]> |
13
|
|
|
* @author Richard Browne <[email protected]> |
14
|
|
|
* @copyright 2020 pw-websolutions.com |
15
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License |
16
|
|
|
* @method static self none() |
17
|
|
|
* @method static self standard() |
18
|
|
|
* @method static self reduced() |
19
|
|
|
* @method static self zero() |
20
|
|
|
*/ |
21
|
|
|
abstract class Type extends Enum |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* No type for the Tax. |
25
|
|
|
* |
26
|
|
|
* @return Type |
27
|
|
|
*/ |
28
|
|
|
public static function none(): self |
29
|
|
|
{ |
30
|
|
|
return new class() extends Type { |
31
|
|
|
// phpcs:ignore |
32
|
|
|
public function getIndex(): int |
33
|
|
|
{ |
34
|
|
|
return 0; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// phpcs:ignore |
38
|
|
|
public function getValue(): string |
39
|
|
|
{ |
40
|
|
|
$value = __(''); |
41
|
|
|
|
42
|
|
|
if (true === is_array($value)) { |
43
|
|
|
$value = (string) $value[0]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $value ?: ''; |
47
|
|
|
} |
48
|
|
|
}; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Standard Rate type for the Tax. |
53
|
|
|
* |
54
|
|
|
* @return Type |
55
|
|
|
*/ |
56
|
|
|
public static function standard(): self |
57
|
|
|
{ |
58
|
|
|
return new class() extends Type { |
59
|
|
|
// phpcs:ignore |
60
|
|
|
public function getIndex(): int |
61
|
|
|
{ |
62
|
|
|
return 1; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// phpcs:ignore |
66
|
|
|
public function getValue(): string |
67
|
|
|
{ |
68
|
|
|
$value = __('pwweb::localisation.tax.rates.standard_rate'); |
69
|
|
|
|
70
|
|
|
if (true === is_array($value)) { |
71
|
|
|
$value = (string) $value[0]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $value ?: ''; |
75
|
|
|
} |
76
|
|
|
}; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Reduced Rate type for the Tax. |
81
|
|
|
* |
82
|
|
|
* @return Type |
83
|
|
|
*/ |
84
|
|
|
public static function reduced(): self |
85
|
|
|
{ |
86
|
|
|
return new class() extends Type { |
87
|
|
|
// phpcs:ignore |
88
|
|
|
public function getIndex(): int |
89
|
|
|
{ |
90
|
|
|
return 2; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// phpcs:ignore |
94
|
|
|
public function getValue(): string |
95
|
|
|
{ |
96
|
|
|
$value = __('pwweb::localisation.tax.rates.reduced_rate'); |
97
|
|
|
|
98
|
|
|
if (true === is_array($value)) { |
99
|
|
|
$value = (string) $value[0]; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return $value ?: ''; |
103
|
|
|
} |
104
|
|
|
}; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Zero Rate type for the Tax. |
109
|
|
|
* |
110
|
|
|
* @return Type |
111
|
|
|
*/ |
112
|
|
|
public static function zero(): self |
113
|
|
|
{ |
114
|
|
|
return new class() extends Type { |
115
|
|
|
// phpcs:ignore |
116
|
|
|
public function getIndex(): int |
117
|
|
|
{ |
118
|
|
|
return 3; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// phpcs:ignore |
122
|
|
|
public function getValue(): string |
123
|
|
|
{ |
124
|
|
|
$value = __('pwweb::localisation.tax.rates.zero_rate'); |
125
|
|
|
|
126
|
|
|
if (true === is_array($value)) { |
127
|
|
|
$value = (string) $value[0]; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
return $value ?: ''; |
131
|
|
|
} |
132
|
|
|
}; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|