1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the {@see Mailcode_Commands_Command_ShowVariable} class. |
4
|
|
|
* |
5
|
|
|
* @package Mailcode |
6
|
|
|
* @subpackage Commands |
7
|
|
|
* @see Mailcode_Commands_Command_ShowVariable |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Mailcode; |
13
|
|
|
|
14
|
|
|
use Mailcode\Interfaces\Commands\Validation\DecryptInterface; |
15
|
|
|
use Mailcode\Interfaces\Commands\Validation\IDNEncodingInterface; |
16
|
|
|
use Mailcode\Traits\Commands\Validation\DecryptTrait; |
17
|
|
|
use Mailcode\Traits\Commands\Validation\IDNDecodeTrait; |
18
|
|
|
use Mailcode\Traits\Commands\Validation\IDNEncodeTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Mailcode command: show a variable value. |
22
|
|
|
* |
23
|
|
|
* @package Mailcode |
24
|
|
|
* @subpackage Commands |
25
|
|
|
* @author Sebastian Mordziol <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class Mailcode_Commands_Command_ShowVariable |
28
|
|
|
extends Mailcode_Commands_ShowBase |
29
|
|
|
implements |
30
|
|
|
IDNEncodingInterface, DecryptInterface |
31
|
|
|
{ |
32
|
|
|
public const VALIDATION_TOO_MANY_PARAMETERS = 69701; |
33
|
|
|
|
34
|
|
|
use IDNEncodeTrait; |
35
|
|
|
use IDNDecodeTrait; |
36
|
|
|
use DecryptTrait; |
37
|
|
|
|
38
|
|
|
public function getName(): string |
39
|
|
|
{ |
40
|
|
|
return 'showvar'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getLabel(): string |
44
|
|
|
{ |
45
|
|
|
return t('Show variable'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function getValidations(): array |
49
|
|
|
{ |
50
|
|
|
return array( |
51
|
|
|
Mailcode_Interfaces_Commands_Validation_Variable::VALIDATION_NAME_VARIABLE, |
52
|
|
|
DecryptInterface::VALIDATION_DECRYPT_NAME |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Gets all validated tokens that the command supports |
58
|
|
|
* (namely the variable, and keywords). |
59
|
|
|
* |
60
|
|
|
* @return Mailcode_Parser_Statement_Tokenizer_Token[] |
61
|
|
|
* @throws Mailcode_Exception |
62
|
|
|
*/ |
63
|
|
|
protected function resolveActiveTokens(): array |
64
|
|
|
{ |
65
|
|
|
$allowed = array($this->getVariableToken()); |
66
|
|
|
|
67
|
|
|
$encodings = $this->getSupportedEncodings(); |
68
|
|
|
|
69
|
|
|
foreach ($encodings as $keyword) { |
70
|
|
|
$token = $this->getEncodingToken($keyword); |
71
|
|
|
if ($token) { |
72
|
|
|
$allowed[] = $token; |
73
|
|
|
|
74
|
|
|
$parameter = $this->requireParams()->getInfo()->getTokenForKeyWord($token->getKeyword()); |
75
|
|
|
if ($parameter) { |
76
|
|
|
$allowed[] = $parameter; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $allowed; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|