1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the class {@see \Mailcode\Factory\CommandSets\Set\Show\Encoded}. |
4
|
|
|
* |
5
|
|
|
* @package Mailcode |
6
|
|
|
* @subpackage Factory |
7
|
|
|
* @see \Mailcode\Factory\CommandSets\Set\Show\Encoded |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Mailcode\Factory\CommandSets\Set\Show; |
13
|
|
|
|
14
|
|
|
use Mailcode\Mailcode_Commands_Command_ShowEncoded; |
15
|
|
|
use Mailcode\Mailcode_Factory_CommandSets_Set; |
16
|
|
|
use Mailcode\Mailcode_Factory_Exception; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Factory class for the `showencoded` command. |
20
|
|
|
* |
21
|
|
|
* @package Mailcode |
22
|
|
|
* @subpackage Factory |
23
|
|
|
* @author Sebastian Mordziol <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class Encoded extends Mailcode_Factory_CommandSets_Set |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @param string $subject |
29
|
|
|
* @param string[] $encodings |
30
|
|
|
* @return Mailcode_Commands_Command_ShowEncoded |
31
|
|
|
* @throws Mailcode_Factory_Exception |
32
|
|
|
*/ |
33
|
|
|
public function create(string $subject, array $encodings) : Mailcode_Commands_Command_ShowEncoded |
34
|
|
|
{ |
35
|
|
|
$paramsString = $this->renderParams($subject, $encodings); |
36
|
|
|
|
37
|
|
|
$cmd = $this->commands->createCommand( |
38
|
|
|
'ShowEncoded', |
39
|
|
|
'', |
40
|
|
|
$paramsString, |
41
|
|
|
'{showencoded: '.$paramsString.'}' |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$this->instantiator->checkCommand($cmd); |
45
|
|
|
|
46
|
|
|
if($cmd instanceof Mailcode_Commands_Command_ShowEncoded) |
47
|
|
|
{ |
48
|
|
|
return $cmd; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ShowEncoded', $cmd); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $subject |
56
|
|
|
* @param string[] $encodings |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
private function renderParams(string $subject, array $encodings) : string |
60
|
|
|
{ |
61
|
|
|
$params = array(); |
62
|
|
|
$params[] = $this->instantiator->quoteString($subject); |
63
|
|
|
|
64
|
|
|
foreach($encodings as $keyword) |
65
|
|
|
{ |
66
|
|
|
$params[] = $this->instantiator->filterKeyword($keyword); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return implode(' ', $params); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|