Passed
Push — master ( d3640a...6ab608 )
by Sebastian
02:29
created
src/Mailcode/Translator/Syntax.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 {
24 24
     const ERROR_UNKNOWN_COMMAND_TYPE = 50401;
25 25
     
26
-   /**
27
-    * Retrieves the syntax' type ID, e.g. "ApacheVelocity".
28
-    * @return string
29
-    */
26
+    /**
27
+     * Retrieves the syntax' type ID, e.g. "ApacheVelocity".
28
+     * @return string
29
+     */
30 30
     public function getTypeID() : string
31 31
     {
32 32
         $parts = explode('_', get_class($this));
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
         return array_pop($parts);
35 35
     }
36 36
     
37
-   /**
38
-    * Translates a single command to the target syntax.
39
-    * 
40
-    * @param Mailcode_Commands_Command $command
41
-    * @throws Mailcode_Translator_Exception
42
-    * @return string
43
-    */
37
+    /**
38
+     * Translates a single command to the target syntax.
39
+     * 
40
+     * @param Mailcode_Commands_Command $command
41
+     * @throws Mailcode_Translator_Exception
42
+     * @return string
43
+     */
44 44
     public function translateCommand(Mailcode_Commands_Command $command) : string
45 45
     {
46 46
         $id = $command->getID();
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
         return $this->$method($command);
64 64
     }
65 65
     
66
-   /**
67
-    * Translates all safeguarded commands in the subject string to the 
68
-    * target syntax in one go.
69
-    * 
70
-    * @param Mailcode_Parser_Safeguard $safeguard
71
-    * @return string
72
-    */
66
+    /**
67
+     * Translates all safeguarded commands in the subject string to the 
68
+     * target syntax in one go.
69
+     * 
70
+     * @param Mailcode_Parser_Safeguard $safeguard
71
+     * @return string
72
+     */
73 73
     public function translateSafeguard(Mailcode_Parser_Safeguard $safeguard) : string
74 74
     {
75 75
         $subject = $safeguard->makeSafe();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         
48 48
         $method = '_translate'.$id;
49 49
         
50
-        if(!method_exists($this, $method))
50
+        if (!method_exists($this, $method))
51 51
         {
52 52
             throw new Mailcode_Translator_Exception(
53 53
                 'Unknown command type in translator',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         $subject = $safeguard->makeSafe();
76 76
         
77
-        if(!$safeguard->hasPlaceholders())
77
+        if (!$safeguard->hasPlaceholders())
78 78
         {
79 79
             return $subject;
80 80
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         
84 84
         $replaces = array();
85 85
         
86
-        foreach($placeholders as $placeholder)
86
+        foreach ($placeholders as $placeholder)
87 87
         {
88 88
             $replaces[$placeholder->getReplacementText()] = $this->translateCommand($placeholder->getCommand());
89 89
         }
Please login to merge, or discard this patch.
src/Mailcode.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Mailcode
28 28
 {
29
-   /**
30
-    * @var Mailcode_Parser|NULL
31
-    */
29
+    /**
30
+     * @var Mailcode_Parser|NULL
31
+     */
32 32
     protected $parser = null;
33 33
     
34
-   /**
35
-    * @var Mailcode_Commands|NULL
36
-    */
34
+    /**
35
+     * @var Mailcode_Commands|NULL
36
+     */
37 37
     protected $commands = null;
38 38
     
39
-   /**
40
-    * @var Mailcode_Variables|NULL
41
-    */
39
+    /**
40
+     * @var Mailcode_Variables|NULL
41
+     */
42 42
     protected $variables = null;
43 43
     
44
-   /**
45
-    * @var Mailcode_Translator|NULL
46
-    */
44
+    /**
45
+     * @var Mailcode_Translator|NULL
46
+     */
47 47
     protected $translator = null;
48 48
     
49
-   /**
50
-    * Creates a new mailcode instance.
51
-    * @return Mailcode
52
-    */
49
+    /**
50
+     * Creates a new mailcode instance.
51
+     * @return Mailcode
52
+     */
53 53
     public static function create() : Mailcode
54 54
     {
55 55
         return new Mailcode();
56 56
     }
57 57
     
58
-   /**
59
-    * Parses the string to detect all commands contained within.
60
-    * 
61
-    * @param string $string
62
-    * @return Mailcode_Collection
63
-    */
58
+    /**
59
+     * Parses the string to detect all commands contained within.
60
+     * 
61
+     * @param string $string
62
+     * @return Mailcode_Collection
63
+     */
64 64
     public function parseString(string $string) : Mailcode_Collection
65 65
     {
66 66
         return $this->getParser()->parseString($string);
67 67
     }
68 68
     
69
-   /**
70
-    * Retrieves the string parser instance used to detect commands.
71
-    * 
72
-    * @return Mailcode_Parser
73
-    */
69
+    /**
70
+     * Retrieves the string parser instance used to detect commands.
71
+     * 
72
+     * @return Mailcode_Parser
73
+     */
74 74
     public function getParser() : Mailcode_Parser
75 75
     {
76 76
         if(!isset($this->parser)) 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         return $this->parser;
82 82
     }
83 83
     
84
-   /**
85
-    * Retrieves the commands collection, which is used to
86
-    * access information on the available commands.
87
-    * 
88
-    * @return Mailcode_Commands
89
-    */
84
+    /**
85
+     * Retrieves the commands collection, which is used to
86
+     * access information on the available commands.
87
+     * 
88
+     * @return Mailcode_Commands
89
+     */
90 90
     public function getCommands() : Mailcode_Commands
91 91
     {
92 92
         if(!isset($this->commands)) 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
         return $this->getParser()->createSafeguard($subject);
103 103
     }
104 104
     
105
-   /**
106
-    * Attempts to find all variables in the target string.
107
-    * 
108
-    * @param string $subject
109
-    * @return Mailcode_Variables_Collection_Regular
110
-    */
105
+    /**
106
+     * Attempts to find all variables in the target string.
107
+     * 
108
+     * @param string $subject
109
+     * @return Mailcode_Variables_Collection_Regular
110
+     */
111 111
     public function findVariables(string $subject) : Mailcode_Variables_Collection_Regular
112 112
     {
113 113
         return $this->createVariables()->parseString($subject);
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
         return $this->variables;
124 124
     }
125 125
     
126
-   /**
127
-    * Creates the translator, which can be used to convert commands
128
-    * to another supported syntax.
129
-    * 
130
-    * @return Mailcode_Translator
131
-    */
126
+    /**
127
+     * Creates the translator, which can be used to convert commands
128
+     * to another supported syntax.
129
+     * 
130
+     * @return Mailcode_Translator
131
+     */
132 132
     public function createTranslator() : Mailcode_Translator
133 133
     {
134 134
         if(!isset($this->translator))
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     */
74 74
     public function getParser() : Mailcode_Parser
75 75
     {
76
-        if(!isset($this->parser)) 
76
+        if (!isset($this->parser)) 
77 77
         {
78 78
             $this->parser = new Mailcode_Parser($this);
79 79
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     */
90 90
     public function getCommands() : Mailcode_Commands
91 91
     {
92
-        if(!isset($this->commands)) 
92
+        if (!isset($this->commands)) 
93 93
         {
94 94
             $this->commands = new Mailcode_Commands();
95 95
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     
116 116
     public function createVariables() : Mailcode_Variables
117 117
     {
118
-        if(!isset($this->variables))
118
+        if (!isset($this->variables))
119 119
         {
120 120
             $this->variables = new Mailcode_Variables();
121 121
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     */
132 132
     public function createTranslator() : Mailcode_Translator
133 133
     {
134
-        if(!isset($this->translator))
134
+        if (!isset($this->translator))
135 135
         {
136 136
             $this->translator = new Mailcode_Translator(); 
137 137
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
     
30 30
     const VALIDATION_UNQUOTED_STRING_LITERALS = 48802;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $statement;
36 36
     
37
-   /**
38
-    * @var OperationResult
39
-    */
37
+    /**
38
+     * @var OperationResult
39
+     */
40 40
     protected $result;
41 41
     
42
-   /**
43
-    * @var Mailcode_Parser_Statement_Tokenizer|NULL
44
-    */
42
+    /**
43
+     * @var Mailcode_Parser_Statement_Tokenizer|NULL
44
+     */
45 45
     protected $tokenizer;
46 46
     
47
-   /**
48
-    * @var Mailcode_Parser_Statement_Info|NULL
49
-    */
47
+    /**
48
+     * @var Mailcode_Parser_Statement_Info|NULL
49
+     */
50 50
     protected $info;
51 51
     
52 52
     public function __construct(string $statement)
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         if($unknown)
103 103
         {
104 104
             $this->result->makeError(
105
-               t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
105
+                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
106 106
                 self::VALIDATION_UNQUOTED_STRING_LITERALS
107 107
             );
108 108
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     
76 76
     public function getInfo() : Mailcode_Parser_Statement_Info
77 77
     {
78
-        if(isset($this->info))
78
+        if (isset($this->info))
79 79
         {
80 80
             return $this->info; 
81 81
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     
88 88
     protected function validate() : void
89 89
     {
90
-        if(!$this->tokenizer->hasTokens())
90
+        if (!$this->tokenizer->hasTokens())
91 91
         {
92 92
             $this->result->makeError(
93 93
                 t('Empty statement'),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         $unknown = $this->tokenizer->getFirstUnknown();
101 101
         
102
-        if($unknown)
102
+        if ($unknown)
103 103
         {
104 104
             $this->result->makeError(
105 105
                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/Comment.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         $this->paramsString = trim($this->paramsString);
26 26
         
27 27
         // automatically quote the parameters, since comments don't require any.
28
-        if(substr($this->paramsString, 0, 1) != '"')
28
+        if (substr($this->paramsString, 0, 1) != '"')
29 29
         {
30 30
             $this->paramsString = '"'.$this->paramsString.'"';
31 31
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowSnippet.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
     
25 25
     const VALIDATION_VARIABLE_COUNT_MISMATCH = 52001;
26 26
     
27
-   /**
28
-    * @var Mailcode_Variables_Variable|NULL
29
-    */
27
+    /**
28
+     * @var Mailcode_Variables_Variable|NULL
29
+     */
30 30
     protected $variable;
31 31
     
32 32
     public function getName() : string
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         return true;
50 50
     }
51 51
     
52
-   /**
53
-    * Retrieves the variable to show.
54
-    * 
55
-    * NOTE: Only available once the command has been
56
-    * validated. Always use isValid() first.
57
-    * 
58
-    * @throws Mailcode_Exception
59
-    * @return Mailcode_Variables_Variable
60
-    */
52
+    /**
53
+     * Retrieves the variable to show.
54
+     * 
55
+     * NOTE: Only available once the command has been
56
+     * validated. Always use isValid() first.
57
+     * 
58
+     * @throws Mailcode_Exception
59
+     * @return Mailcode_Variables_Variable
60
+     */
61 61
     public function getVariable() : Mailcode_Variables_Variable
62 62
     {
63 63
         $this->validate();
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
         );
75 75
     }
76 76
     
77
-   /**
78
-    * Retrieves the full name of the variable to show.
79
-    * 
80
-    * NOTE: Only available once the command has been
81
-    * validated. Always use isValid() first.
82
-    * 
83
-    * @throws Mailcode_Exception
84
-    * @return string
85
-    */
77
+    /**
78
+     * Retrieves the full name of the variable to show.
79
+     * 
80
+     * NOTE: Only available once the command has been
81
+     * validated. Always use isValid() first.
82
+     * 
83
+     * @throws Mailcode_Exception
84
+     * @return string
85
+     */
86 86
     public function getVariableName() : string
87 87
     {
88 88
         return $this->getVariable()->getFullName();
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 
91 91
     protected function validateSyntax_require_variable() : void
92 92
     {
93
-         $vars = $this->getVariables()->getGroupedByName();
94
-         $amount = count($vars);
93
+            $vars = $this->getVariables()->getGroupedByName();
94
+            $amount = count($vars);
95 95
          
96
-         if($amount === 1)
97
-         {
98
-             $this->variable = array_pop($vars);
99
-             return;
100
-         }
96
+            if($amount === 1)
97
+            {
98
+                $this->variable = array_pop($vars);
99
+                return;
100
+            }
101 101
          
102
-         $this->validationResult->makeError(
102
+            $this->validationResult->makeError(
103 103
             t('Command has %1$s variables, %2$s expected.', $amount, 1),
104 104
             self::VALIDATION_VARIABLE_COUNT_MISMATCH
105
-         );
105
+            );
106 106
     }
107 107
     
108 108
     protected function getValidations() : array
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $this->validate();
64 64
         
65
-        if(isset($this->variable))
65
+        if (isset($this->variable))
66 66
         {
67 67
             return $this->variable;
68 68
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
          $vars = $this->getVariables()->getGroupedByName();
94 94
          $amount = count($vars);
95 95
          
96
-         if($amount === 1)
96
+         if ($amount === 1)
97 97
          {
98 98
              $this->variable = array_pop($vars);
99 99
              return;
Please login to merge, or discard this patch.