| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | class Snippet extends Mailcode_Factory_CommandSets_Set |
||
| 26 | { |
||
| 27 | public function create(string $snippetName, string $namespace = null): Mailcode_Commands_Command_ShowSnippet |
||
| 28 | { |
||
| 29 | $snippetName = $this->instantiator->filterVariableName($snippetName); |
||
| 30 | $paramsString = $this->compileParams($namespace); |
||
| 31 | |||
| 32 | $cmd = $this->commands->createCommand( |
||
| 33 | 'ShowSnippet', |
||
| 34 | '', |
||
| 35 | $snippetName . $paramsString, |
||
| 36 | sprintf('{showsnippet: %s%s', |
||
| 37 | $snippetName, |
||
| 38 | $paramsString) |
||
| 39 | ); |
||
| 40 | |||
| 41 | $this->instantiator->checkCommand($cmd); |
||
| 42 | |||
| 43 | if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet) { |
||
| 44 | return $cmd; |
||
| 45 | } |
||
| 46 | |||
| 47 | throw $this->instantiator->exceptionUnexpectedType('ShowSnippet', $cmd); |
||
| 48 | } |
||
| 49 | |||
| 50 | private function compileParams(string $namespace = null): string |
||
| 66 | } |
||
| 67 | } |
||
| 68 |