Passed
Push — master ( d8dc61...dfdb64 )
by Sebastian
09:05
created

ShowURLTranslation::translate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @package Mailcode
4
 * @subpackage Translator
5
 */
6
7
declare(strict_types=1);
8
9
namespace Mailcode\Translator\Syntax\HubL;
10
11
use AppUtils\ConvertHelper;
12
use Mailcode\Mailcode;
13
use Mailcode\Mailcode_Commands_Command_ShowURL;
14
use Mailcode\Translator\Syntax\ApacheVelocity;
15
use Mailcode\Translator\Syntax\HubL;
16
use Mailcode\Translator\Command\ShowURLInterface;
17
use testsuites\Translator\HubL\ShowURLTests;
0 ignored issues
show
Bug introduced by
The type testsuites\Translator\HubL\ShowURLTests was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 * Translates the {@see Mailcode_Commands_Command_ShowURL} command to HubL.
21
 *
22
 * @package Mailcode
23
 * @subpackage Translator
24
 * @author Sebastian Mordziol <[email protected]>
25
 *
26
 * @see ShowURLTests
27
 */
28
class ShowURLTranslation extends HubL implements ShowURLInterface
29
{
30
    public function translate(Mailcode_Commands_Command_ShowURL $command) : string
31
    {
32
        return $this->resolveURL($command);
33
    }
34
35
    private function resolveURL(Mailcode_Commands_Command_ShowURL $command) : string
36
    {
37
        // Remove newlines in the content.
38
        $content = trim(str_replace(array("\r", "\n"), '', $command->getContent()));
39
40
        $safeguard = Mailcode::create()->createSafeguard($content);
41
42
        return Mailcode::create()->createTranslator()
43
            ->createSyntax($this->getSyntaxName())
44
            ->translateSafeguard($safeguard);
45
    }
46
}
47