Test Failed
Push — master ( 9ff364...742ef2 )
by Sebastian
03:58
created

Mailcode_Factory_CommandSets_Set_Show   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 78
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A snippet() 0 3 1
A encoded() 0 3 1
A url() 0 3 1
A date() 0 3 1
A number() 0 3 1
A phone() 0 3 1
A var() 0 19 2
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Factory_CommandSets_Set_Show} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Factory
7
 * @see Mailcode_Factory_CommandSets_Set_Show
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use Mailcode\Factory\CommandSets\Set\Show\Date;
15
use Mailcode\Factory\CommandSets\Set\Show\Encoded;
0 ignored issues
show
Bug introduced by
The type Mailcode\Factory\CommandSets\Set\Show\Encoded 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...
16
use Mailcode\Factory\CommandSets\Set\Show\Number;
17
use Mailcode\Factory\CommandSets\Set\Show\Phone;
18
use Mailcode\Factory\CommandSets\Set\Show\Snippet;
19
use Mailcode\Factory\CommandSets\Set\Show\URL;
20
21
/**
22
 * Command set used to create showxxx commands.
23
 *
24
 * @package Mailcode
25
 * @subpackage Factory
26
 * @author Sebastian Mordziol <[email protected]>
27
 */
28
class Mailcode_Factory_CommandSets_Set_Show extends Mailcode_Factory_CommandSets_Set
29
{
30
    public function var(string $variableName) : Mailcode_Commands_Command_ShowVariable
31
    {
32
        $variableName = $this->instantiator->filterVariableName($variableName);
33
        
34
        $cmd = $this->commands->createCommand(
35
            'ShowVariable',
36
            '',
37
            $variableName,
38
            '{showvar:'.$variableName.'}'
39
        );
40
        
41
        $this->instantiator->checkCommand($cmd);
42
        
43
        if($cmd instanceof Mailcode_Commands_Command_ShowVariable)
44
        {
45
            return $cmd;
46
        }
47
        
48
        throw $this->instantiator->exceptionUnexpectedType('ShowVariable', $cmd);
49
    }
50
    
51
    public function date(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate
52
    {
53
        return (new Date())->create($variableName, $formatString);
54
    }
55
56
    public function number(string $variableName, string $formatString="", bool $absolute=false) : Mailcode_Commands_Command_ShowNumber
57
    {
58
        return (new Number())->create($variableName, $formatString, $absolute);
59
    }
60
61
    /**
62
     * Creates a `showphone` command.
63
     *
64
     * @param string $variableName The name of the variable, with or without $ sign.
65
     * @param string $sourceFormat Two-letter country code, case-insensitive.
66
     * @param string $urlEncoding The URL encoding mode, if any.
67
     * @return Mailcode_Commands_Command_ShowPhone
68
     * @throws Mailcode_Factory_Exception
69
     */
70
    public function phone(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone
71
    {
72
        return (new Phone())->create($variableName, $sourceFormat, $urlEncoding);
73
    }
74
75
    /**
76
     * @param string $snippetName The name of the snippet to show.
77
     * @return Mailcode_Commands_Command_ShowSnippet
78
     * @throws Mailcode_Factory_Exception
79
     */
80
    public function snippet(string $snippetName) : Mailcode_Commands_Command_ShowSnippet
81
    {
82
        return (new Snippet())->create($snippetName);
83
    }
84
85
    /**
86
     * @param string $url The target URL. Can contain Mailcode.
87
     * @param string|null $trackingID If not set, an auto-generated tracking ID will be used.
88
     * @param array<string,string> $queryParams
89
     * @return Mailcode_Commands_Command_ShowURL
90
     * @throws Mailcode_Factory_Exception
91
     */
92
    public function url(string $url, ?string $trackingID=null, array $queryParams=array()) : Mailcode_Commands_Command_ShowURL
93
    {
94
        return (new URL())->create($url, $trackingID, $queryParams);
95
    }
96
97
    /**
98
     * @param string $subject The string to encode
99
     * @param string[] $encodings The encodings (keywords) to enable
100
     * @return Mailcode_Commands_Command_ShowEncoded
101
     * @throws Mailcode_Factory_Exception
102
     */
103
    public function encoded(string $subject, array $encodings) : Mailcode_Commands_Command_ShowEncoded
0 ignored issues
show
Bug introduced by
The type Mailcode\Mailcode_Commands_Command_ShowEncoded 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...
104
    {
105
        return(new Encoded())->create($subject, $encodings);
106
    }
107
}
108