|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File containing the class {@see \Mailcode\Factory\CommandSets\Set\Show\Phone}. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Mailcode |
|
6
|
|
|
* @subpackage Factory |
|
7
|
|
|
* @see \Mailcode\Factory\CommandSets\Set\Show\Phone |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Mailcode\Factory\CommandSets\Set\Show; |
|
13
|
|
|
|
|
14
|
|
|
use Mailcode\Mailcode_Commands_Command_ShowPhone; |
|
15
|
|
|
use Mailcode\Mailcode_Exception; |
|
16
|
|
|
use Mailcode\Mailcode_Factory; |
|
17
|
|
|
use Mailcode\Mailcode_Factory_CommandSets_Set; |
|
18
|
|
|
use Mailcode\Mailcode_Factory_Exception; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Factory class for the `showphone` command. |
|
22
|
|
|
* |
|
23
|
|
|
* @package Mailcode |
|
24
|
|
|
* @subpackage Factory |
|
25
|
|
|
* @author Sebastian Mordziol <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class Phone extends Mailcode_Factory_CommandSets_Set |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Creates a `showphone` command. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $variableName The name of the variable, with or without $ sign. |
|
33
|
|
|
* @param string $sourceFormat Two-letter country code, case-insensitive. |
|
34
|
|
|
* @param string $urlEncoding The URL encoding mode, if any. |
|
35
|
|
|
* @return Mailcode_Commands_Command_ShowPhone |
|
36
|
|
|
* @throws Mailcode_Factory_Exception |
|
37
|
|
|
*/ |
|
38
|
|
|
public function create(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone |
|
39
|
|
|
{ |
|
40
|
|
|
$variableName = $this->instantiator->filterVariableName($variableName); |
|
41
|
|
|
|
|
42
|
|
|
$params = sprintf( |
|
43
|
|
|
'%s "%s"', |
|
44
|
|
|
$variableName, |
|
45
|
|
|
strtoupper($sourceFormat) |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
$cmd = $this->commands->createCommand( |
|
49
|
|
|
'ShowPhone', |
|
50
|
|
|
'', |
|
51
|
|
|
$params, |
|
52
|
|
|
sprintf( |
|
53
|
|
|
'{showphone: %s}', |
|
54
|
|
|
$params |
|
55
|
|
|
) |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
$this->instantiator->checkCommand($cmd); |
|
59
|
|
|
$this->instantiator->setEncoding($cmd, $urlEncoding); |
|
60
|
|
|
|
|
61
|
|
|
if($cmd instanceof Mailcode_Commands_Command_ShowPhone) |
|
62
|
|
|
{ |
|
63
|
|
|
return $cmd; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ShowPhone', $cmd); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|