Passed
Push — master ( 0c35c3...4c9016 )
by Sebastian
03:25 queued 12s
created

Mailcode_Factory::setVarString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 3
b 0
f 1
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Factory} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Utilities
7
 * @see Mailcode_Factory
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Factory utility used to create commands.
16
 *
17
 * @package Mailcode
18
 * @subpackage Utilities
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Factory
22
{
23
    const ERROR_INVALID_COMMAND_CREATED = 50001;
24
    const ERROR_UNEXPECTED_COMMAND_TYPE = 50002;
25
26
   /**
27
    * @var Mailcode_Factory_CommandSets
28
    */
29
    private static $commandSets;
30
31
    /**
32
     * Returns the command set for `show` commands.
33
     *
34
     * @return Mailcode_Factory_CommandSets_Set_Show
35
     */
36
    public static function show() : Mailcode_Factory_CommandSets_Set_Show
37
    {
38
        return self::$commandSets->show();
39
    }
40
41
    /**
42
     * Return the command set for `set` commands.
43
     *
44
     * @return Mailcode_Factory_CommandSets_Set_Set
45
     */
46
    public static function set() : Mailcode_Factory_CommandSets_Set_Set
47
    {
48
        return self::$commandSets->set();
49
    }
50
51
    /**
52
     * Return the command set for `if` commands.
53
     *
54
     * @return Mailcode_Factory_CommandSets_Set_If
55
     */
56
    public static function if() : Mailcode_Factory_CommandSets_Set_If
57
    {
58
        return self::$commandSets->if();
59
    }
60
61
    /**
62
     * Return the command set for `else if` commands.
63
     *
64
     * @return Mailcode_Factory_CommandSets_Set_ElseIf
65
     */
66
    public static function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf
67
    {
68
        return self::$commandSets->elseIf();
69
    }
70
71
    /**
72
     * Return the command set for `miscellaneous` commands.
73
     *
74
     * @return Mailcode_Factory_CommandSets_Set_Misc
75
     */
76
    public static function misc() : Mailcode_Factory_CommandSets_Set_Misc
77
    {
78
        return self::$commandSets->misc();
79
    }
80
81
    /**
82
    * Creates a renderer instance, which can be used to easily
83
    * create and convert commands to strings.
84
    * 
85
    * @return Mailcode_Renderer
86
    */
87
    public static function createRenderer() : Mailcode_Renderer
88
    {
89
        return new Mailcode_Renderer();
90
    }
91
    
92
   /**
93
    * Creates a printer instance, which works like the renderer,
94
    * but outputs the generated strings to standard output.
95
    * 
96
    * @return Mailcode_Printer
97
    */
98
    public static function createPrinter() : Mailcode_Printer
99
    {
100
        return new Mailcode_Printer();
101
    }
102
    
103
   /**
104
    * Gets/creates the global instance of the date format info
105
    * class, used to handle date formatting aspects.
106
    * 
107
    * @return Mailcode_Date_FormatInfo
108
    */
109
    public static function createDateInfo() : Mailcode_Date_FormatInfo
110
    {
111
        return Mailcode_Date_FormatInfo::getInstance();
112
    }
113
114
    public static function init() : void
115
    {
116
        if(!isset(self::$commandSets))
117
        {
118
            self::$commandSets = new Mailcode_Factory_CommandSets();
119
        }
120
    }
121
}
122
123
Mailcode_Factory::init();
124