1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the {@see Mailcode_Commands_Command_ShowPrice} class. |
4
|
|
|
* |
5
|
|
|
* @package Mailcode |
6
|
|
|
* @subpackage Commands |
7
|
|
|
* @see Mailcode_Commands_Command_ShowPrice |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Mailcode; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Mailcode command: show a date variable value. |
16
|
|
|
* |
17
|
|
|
* @package Mailcode |
18
|
|
|
* @subpackage Commands |
19
|
|
|
* @author Olaf Böcker <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Mailcode_Commands_Command_ShowPrice extends Mailcode_Commands_ShowBase |
22
|
|
|
implements |
23
|
|
|
CurrencyNameInterface |
24
|
|
|
{ |
25
|
|
|
public const VALIDATION_CODE_1 = 163401; |
26
|
|
|
|
27
|
|
|
use CurrencyNameTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
31
|
|
|
*/ |
32
|
|
|
private ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword $absoluteKeyword = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var Mailcode_Number_LocalCurrency |
36
|
|
|
*/ |
37
|
|
|
private Mailcode_Number_LocalCurrency $localCurrency; |
38
|
|
|
|
39
|
|
|
public function getName(): string |
40
|
|
|
{ |
41
|
|
|
return 'showprice'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getLabel(): string |
45
|
|
|
{ |
46
|
|
|
return t('Show price variable'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
protected function getValidations(): array |
50
|
|
|
{ |
51
|
|
|
return array( |
52
|
|
|
Mailcode_Interfaces_Commands_Validation_Variable::VALIDATION_NAME_VARIABLE, |
53
|
|
|
'absolute' |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function validateSyntax_absolute(): void |
58
|
|
|
{ |
59
|
|
|
$keywords = $this->requireParams() |
60
|
|
|
->getInfo() |
61
|
|
|
->getKeywords(); |
62
|
|
|
|
63
|
|
|
foreach ($keywords as $keyword) { |
64
|
|
|
if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE) { |
65
|
|
|
$this->absoluteKeyword = $keyword; |
66
|
|
|
break; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function isAbsolute(): bool |
72
|
|
|
{ |
73
|
|
|
return isset($this->absoluteKeyword); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function setAbsolute(bool $absolute): Mailcode_Commands_Command_ShowPrice |
77
|
|
|
{ |
78
|
|
|
if ($absolute === false && isset($this->absoluteKeyword)) { |
79
|
|
|
$this->requireParams()->getInfo()->removeKeyword($this->absoluteKeyword->getKeyword()); |
|
|
|
|
80
|
|
|
$this->absoluteKeyword = null; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if ($absolute === true && !isset($this->absoluteKeyword)) { |
84
|
|
|
$this->requireParams() |
85
|
|
|
->getInfo() |
86
|
|
|
->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE); |
87
|
|
|
|
88
|
|
|
$this->validateSyntax_absolute(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getLocalCurrency(): Mailcode_Number_LocalCurrency |
95
|
|
|
{ |
96
|
|
|
if (!isset($this->localCurrency)) { |
97
|
|
|
$this->localCurrency = Mailcode_Number_LocalCurrency::defaultInstance(); |
98
|
|
|
} |
99
|
|
|
return $this->localCurrency; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setLocalCurrency(Mailcode_Number_LocalCurrency $localCurrency): Mailcode_Commands_Command_ShowPrice |
103
|
|
|
{ |
104
|
|
|
$this->localCurrency = $localCurrency; |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.