Passed
Push — master ( 474736...2851e6 )
by Sebastian
03:40
created
src/Mailcode/Commands/Command/Mono.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $literals = $this->params->getInfo()->getStringLiterals();
86 86
 
87
-        if(empty($literals)) {
87
+        if (empty($literals)) {
88 88
             return;
89 89
         }
90 90
 
91
-        foreach($literals as $literal)
91
+        foreach ($literals as $literal)
92 92
         {
93 93
             $parts = ConvertHelper::explodeTrim(' ', $literal->getText());
94 94
 
95
-            foreach($parts as $part) {
95
+            foreach ($parts as $part) {
96 96
                 $this->addClass($part);
97 97
             }
98 98
         }
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $className = trim($className);
108 108
 
109
-        if($this->isClassNameValid($className))
109
+        if ($this->isClassNameValid($className))
110 110
         {
111
-            if(!in_array($className, $this->classes)) {
111
+            if (!in_array($className, $this->classes)) {
112 112
                 $this->classes[] = $className;
113 113
             }
114 114
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function preProcessOpening(): string
142 142
     {
143
-        if($this->isMultiline()) {
143
+        if ($this->isMultiline()) {
144 144
             return sprintf('<pre%s>', $this->renderAttributes());
145 145
         }
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function preProcessClosing(): string
151 151
     {
152
-        if($this->isMultiline()) {
152
+        if ($this->isMultiline()) {
153 153
             return '</pre>';
154 154
         }
155 155
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     private function renderAttributes() : string
160 160
     {
161
-        if(empty($this->classes)) {
161
+        if (empty($this->classes)) {
162 162
             return '';
163 163
         }
164 164
 
Please login to merge, or discard this patch.
src/Mailcode/Collection/NestingValidator.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
         
61 61
         $commands = $this->collection->getCommands();
62 62
         
63
-        foreach($commands as $command)
63
+        foreach ($commands as $command)
64 64
         {
65 65
             $method = 'validate_'.$command->getCommandType();
66 66
             
67
-            if(!method_exists($this, $method))
67
+            if (!method_exists($this, $method))
68 68
             {
69 69
                 throw new Mailcode_Exception(
70 70
                     'Unknown command type validation method.',
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
             
80 80
             $this->$method($command);
81 81
             
82
-            if(!$this->validationResult->isValid())
82
+            if (!$this->validationResult->isValid())
83 83
             {
84 84
                 break;
85 85
             }
86 86
         }
87 87
         
88
-        if($this->validationResult->isValid())
88
+        if ($this->validationResult->isValid())
89 89
         {
90 90
             $this->validate_Unclosed();
91 91
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $leftover = $this->getOpenCommand();
99 99
         
100
-        if($leftover === null)
100
+        if ($leftover === null)
101 101
         {
102 102
             return;
103 103
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     
114 114
     protected function getOpenCommand() : ?Mailcode_Commands_Command_Type_Opening
115 115
     {
116
-        if(empty($this->stack))
116
+        if (empty($this->stack))
117 117
         {
118 118
             return null;
119 119
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         
125 125
         $cmd = $this->stack[$idx];
126 126
         
127
-        if($cmd instanceof Mailcode_Commands_Command_Type_Opening)
127
+        if ($cmd instanceof Mailcode_Commands_Command_Type_Opening)
128 128
         {
129 129
             return $cmd;
130 130
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $parent = $this->getOpenCommand();
150 150
         
151
-        if($parent === null)
151
+        if ($parent === null)
152 152
         {
153 153
             $this->validationResult->makeError(
154 154
                 t(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             return;
163 163
         }
164 164
         
165
-        if($parent->getName() !== $command->getParentName())
165
+        if ($parent->getName() !== $command->getParentName())
166 166
         {
167 167
             $this->validationResult->makeError(
168 168
                 t(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     
185 185
     protected function validate_Closing(Mailcode_Commands_Command_Type_Closing $command) : void
186 186
     {
187
-        if(empty($this->stack))
187
+        if (empty($this->stack))
188 188
         {
189 189
             $this->validationResult->makeError(
190 190
                 t('All open commands have already been ended.'),
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         
197 197
         $openingCommand = array_pop($this->stack);
198 198
 
199
-        if($openingCommand instanceof Mailcode_Commands_Command_Type_Opening)
199
+        if ($openingCommand instanceof Mailcode_Commands_Command_Type_Opening)
200 200
         {
201 201
             $this->log(sprintf('Closing command %s', $openingCommand->getName()));
202 202
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
30 30
     const VALIDATION_UNCLOSED_COMMAND = 49104;
31 31
     const VALIDATION_CLOSING_NON_OPENING_COMMAND = 49105;
32 32
     
33
-   /**
34
-    * @var Mailcode_Collection
35
-    */
33
+    /**
34
+     * @var Mailcode_Collection
35
+     */
36 36
     protected $collection;
37 37
     
38
-   /**
39
-    * @var OperationResult
40
-    */
38
+    /**
39
+     * @var OperationResult
40
+     */
41 41
     protected $validationResult;
42 42
     
43
-   /**
44
-    * @var Mailcode_Commands_Command_Type[]
45
-    */
43
+    /**
44
+     * @var Mailcode_Commands_Command_Type[]
45
+     */
46 46
     protected $stack = array();
47 47
     
48 48
     public function __construct(Mailcode_Collection $collection)
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/PreProcessing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
     {
26 26
         $command = $location->getPlaceholder()->getCommand();
27 27
 
28
-        if($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
28
+        if ($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
29 29
         {
30 30
             return $command->preProcessOpening();
31 31
         }
32 32
 
33
-        if($command instanceof Mailcode_Commands_Command_Type_Closing)
33
+        if ($command instanceof Mailcode_Commands_Command_Type_Closing)
34 34
         {
35 35
             $opening = $command->getOpeningCommand();
36 36
 
37
-            if($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
37
+            if ($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
38 38
                 return $opening->preProcessClosing();
39 39
             }
40 40
         }
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/End.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 ending command is tied to a preprocessing command: Since
26 26
         // we do not want to keep these, we return an empty string to strip
27 27
         // it out.
28
-        if($command->getOpeningCommand() instanceof Mailcode_Interfaces_Commands_PreProcessing) {
28
+        if ($command->getOpeningCommand() instanceof Mailcode_Interfaces_Commands_PreProcessing) {
29 29
             return '';
30 30
         }
31 31
 
Please login to merge, or discard this patch.
src/Mailcode/Factory/CommandSets/Set/Show.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         
34 34
         $this->instantiator->checkCommand($cmd);
35 35
         
36
-        if($cmd instanceof Mailcode_Commands_Command_ShowVariable)
36
+        if ($cmd instanceof Mailcode_Commands_Command_ShowVariable)
37 37
         {
38 38
             return $cmd;
39 39
         }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
         throw $this->instantiator->exceptionUnexpectedType('ShowVariable', $cmd);
42 42
     }
43 43
     
44
-    public function date(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate
44
+    public function date(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate
45 45
     {
46 46
         $variableName = $this->instantiator->filterVariableName($variableName);
47 47
         
48 48
         $format = '';
49
-        if(!empty($formatString))
49
+        if (!empty($formatString))
50 50
         {
51 51
             $format = sprintf(
52 52
                 ' "%s"',
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         
68 68
         $this->instantiator->checkCommand($cmd);
69 69
         
70
-        if($cmd instanceof Mailcode_Commands_Command_ShowDate)
70
+        if ($cmd instanceof Mailcode_Commands_Command_ShowDate)
71 71
         {
72 72
             return $cmd;
73 73
         }
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
         throw $this->instantiator->exceptionUnexpectedType('ShowDate', $cmd);
76 76
     }
77 77
 
78
-    public function number(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowNumber
78
+    public function number(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowNumber
79 79
     {
80 80
         $variableName = $this->instantiator->filterVariableName($variableName);
81 81
 
82 82
         $format = '';
83
-        if(!empty($formatString))
83
+        if (!empty($formatString))
84 84
         {
85 85
             $format = sprintf(
86 86
                 ' "%s"',
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
         $this->instantiator->checkCommand($cmd);
103 103
 
104
-        if($cmd instanceof Mailcode_Commands_Command_ShowNumber)
104
+        if ($cmd instanceof Mailcode_Commands_Command_ShowNumber)
105 105
         {
106 106
             return $cmd;
107 107
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      * @throws Mailcode_Exception
120 120
      * @throws Mailcode_Factory_Exception
121 121
      */
122
-    public function phone(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone
122
+    public function phone(string $variableName, string $sourceFormat, string $urlEncoding = Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone
123 123
     {
124 124
         $variableName = $this->instantiator->filterVariableName($variableName);
125 125
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $this->instantiator->checkCommand($cmd);
143 143
         $this->instantiator->setEncoding($cmd, $urlEncoding);
144 144
 
145
-        if($cmd instanceof Mailcode_Commands_Command_ShowPhone)
145
+        if ($cmd instanceof Mailcode_Commands_Command_ShowPhone)
146 146
         {
147 147
             return $cmd;
148 148
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         
164 164
         $this->instantiator->checkCommand($cmd);
165 165
         
166
-        if($cmd instanceof Mailcode_Commands_Command_ShowSnippet)
166
+        if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet)
167 167
         {
168 168
             return $cmd;
169 169
         }
Please login to merge, or discard this patch.
tools/prepend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 declare(strict_types=1);
4 4
 
5
-if(!file_exists('../vendor/autoload.php')) {
5
+if (!file_exists('../vendor/autoload.php')) {
6 6
     die('Autoloader not present.');
7 7
 }
8 8
 
Please login to merge, or discard this patch.
tools/translator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 $error = null;
31 31
 $activeSyntax = $syntaxes[0]->getTypeID();
32 32
 
33
-if($request->getBool('translate'))
33
+if ($request->getBool('translate'))
34 34
 {
35 35
     $commandsText = $request->getParam('mailcode');
36 36
     $activeSyntax = (string)$request->registerParam('syntax')
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
         $error = $e->getMessage();
48 48
 
49 49
         $collection = $e->getCollection();
50
-        if($collection)
50
+        if ($collection)
51 51
         {
52 52
             $first = $collection->getFirstError();
53 53
             $error = $first->getMessage();
54 54
             $matched = $first->getMatchedText();
55
-            if(!empty($matched)) {
55
+            if (!empty($matched)) {
56 56
                 $error .= '<br>'.t('In command:').' <code>'.$matched.'</code>';
57 57
             }
58 58
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                             $selected = '';
120 120
                             $typeID = $syntax->getTypeID();
121 121
 
122
-                            if($typeID === $activeSyntax) {
122
+                            if ($typeID === $activeSyntax) {
123 123
                                 $selected = ' selected';
124 124
                             }
125 125
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         <p></p><br>
140 140
         <h2><?php pt('Translated commands') ?></h2>
141 141
         <?php
142
-            if(empty($commandsText))
142
+            if (empty($commandsText))
143 143
             {
144 144
                 ?>
145 145
                     <div class="alert alert-info">
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                     </div>
148 148
                 <?php
149 149
             }
150
-            else if($error)
150
+            else if ($error)
151 151
             {
152 152
                 ?>
153 153
                     <div class="alert alert-danger">
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
     try
41 41
     {
42 42
         $translated = translateMailcode($commandsText, $activeSyntax);
43
-    }
44
-    catch (Mailcode_Exception $e)
43
+    } catch (Mailcode_Exception $e)
45 44
     {
46 45
         $translated = '';
47 46
         $error = $e->getMessage();
@@ -146,8 +145,7 @@  discard block
 block discarded – undo
146 145
                         <?php pt('No commands specified.') ?>
147 146
                     </div>
148 147
                 <?php
149
-            }
150
-            else if($error)
148
+            } else if($error)
151 149
             {
152 150
                 ?>
153 151
                     <div class="alert alert-danger">
@@ -155,8 +153,7 @@  discard block
 block discarded – undo
155 153
                         <?php echo $error ?>
156 154
                     </div>
157 155
                 <?php
158
-            }
159
-            else
156
+            } else
160 157
             {
161 158
                 ?>
162 159
                     <textarea class="form-control" rows="10"><?php echo htmlspecialchars($translated) ?></textarea>
Please login to merge, or discard this patch.
src/Mailcode/Commands.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
     const ERROR_COMMAND_DOES_NOT_EXIST = 45902;
28 28
     const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903;
29 29
     
30
-   /**
31
-    * @var Mailcode_Commands_Command[]
32
-    */
30
+    /**
31
+     * @var Mailcode_Commands_Command[]
32
+     */
33 33
     private $commands = array();
34 34
     
35
-   /**
36
-    * @var array<string,Mailcode_Commands_Command>
37
-    */
35
+    /**
36
+     * @var array<string,Mailcode_Commands_Command>
37
+     */
38 38
     private static $dummyCommands = array();
39 39
     
40
-   /**
41
-    * Retrieves a list of all available command IDs.
42
-    * 
43
-    * @return string[]
44
-    */
40
+    /**
41
+     * Retrieves a list of all available command IDs.
42
+     * 
43
+     * @return string[]
44
+     */
45 45
     public function getIDs() : array
46 46
     {
47 47
         static $ids = array();
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
         return $result;
88 88
     }
89 89
     
90
-   /**
91
-    * Gets an available command by its ID.
92
-    * 
93
-    * @param string $id
94
-    * @return Mailcode_Commands_Command
95
-    */
90
+    /**
91
+     * Gets an available command by its ID.
92
+     * 
93
+     * @param string $id
94
+     * @return Mailcode_Commands_Command
95
+     */
96 96
     public function getByID(string $id) : Mailcode_Commands_Command
97 97
     {
98 98
         static $instances = array();
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
         return $instances[$id];
106 106
     }
107 107
     
108
-   /**
109
-    * Retrieves the ID of a command by its name.
110
-    * 
111
-    * @param string $name
112
-    * @throws Mailcode_Exception
113
-    * @return string
114
-    * 
115
-    * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST
116
-    */
108
+    /**
109
+     * Retrieves the ID of a command by its name.
110
+     * 
111
+     * @param string $name
112
+     * @throws Mailcode_Exception
113
+     * @return string
114
+     * 
115
+     * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST
116
+     */
117 117
     public function getIDByName(string $name) : string
118 118
     {
119 119
         $items = $this->getAll();
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
         return in_array($id, $ids);
143 143
     }
144 144
     
145
-   /**
146
-    * Checks wether the specified name exists.
147
-    * 
148
-    * @param string $name For example: "showvar".
149
-    * @return bool
150
-    */
145
+    /**
146
+     * Checks wether the specified name exists.
147
+     * 
148
+     * @param string $name For example: "showvar".
149
+     * @return bool
150
+     */
151 151
     public function nameExists(string $name) : bool
152 152
     {
153 153
         $items = $this->getAll();
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
         return $class;
202 202
     }
203 203
     
204
-   /**
205
-    * Translates the command type to the expected class naming scheme.
206
-    * 
207
-    * Example: not-empty => NotEmpty
208
-    * 
209
-    * @param string $type
210
-    * @return string
211
-    */
204
+    /**
205
+     * Translates the command type to the expected class naming scheme.
206
+     * 
207
+     * Example: not-empty => NotEmpty
208
+     * 
209
+     * @param string $type
210
+     * @return string
211
+     */
212 212
     private function adjustTypeName(string $type) : string
213 213
     {
214 214
         $type = str_replace('-', ' ', $type);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         static $ids = array();
48 48
         
49
-        if(empty($ids)) {
49
+        if (empty($ids)) {
50 50
             $ids = FileHelper::createFileFinder(__DIR__.'/Commands/Command')
51 51
             ->getPHPClassNames();
52 52
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getAll()
66 66
     {
67
-        if(!empty($this->commands)) {
67
+        if (!empty($this->commands)) {
68 68
             return $this->commands;
69 69
         }
70 70
         
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         
73 73
         $result = array();
74 74
         
75
-        foreach($ids as $id) 
75
+        foreach ($ids as $id) 
76 76
         {
77 77
             $result[] = $this->getDummyCommand($id);
78 78
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         static $instances = array();
99 99
         
100
-        if(!isset($instances[$id])) 
100
+        if (!isset($instances[$id])) 
101 101
         {
102 102
             $instances[$id] = $this->createCommand($id, '__dummy', '', '');
103 103
         }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     {
119 119
         $items = $this->getAll();
120 120
         
121
-        foreach($items as $item) 
121
+        foreach ($items as $item) 
122 122
         {
123
-            if($item->getName() === $name) {
123
+            if ($item->getName() === $name) {
124 124
                 return $item->getID();
125 125
             }
126 126
         }
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
     {
153 153
         $items = $this->getAll();
154 154
         
155
-        foreach($items as $item)
155
+        foreach ($items as $item)
156 156
         {
157
-            if($item->getName() === $name) {
157
+            if ($item->getName() === $name) {
158 158
                 return true;
159 159
             }
160 160
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $class = $this->resolveClassName($id, $type);
168 168
         
169
-        if(!class_exists($class))
169
+        if (!class_exists($class))
170 170
         {
171 171
             throw new Mailcode_Exception(
172 172
                 'No such command',
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
         
189 189
         $dummy = $this->getDummyCommand($id);
190 190
         
191
-        if($dummy->supportsType())
191
+        if ($dummy->supportsType())
192 192
         {
193
-            if(empty($type))
193
+            if (empty($type))
194 194
             {
195 195
                 $type = $dummy->getDefaultType();
196 196
             }
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
      */
229 229
     private function getDummyCommand(string $id) : Mailcode_Commands_Command
230 230
     {
231
-        if(isset(self::$dummyCommands[$id])) {
231
+        if (isset(self::$dummyCommands[$id])) {
232 232
             return self::$dummyCommands[$id];
233 233
         }
234 234
 
235 235
         $class = 'Mailcode\Mailcode_Commands_Command_'.$id;
236 236
         $cmd = new $class('__dummy');
237 237
 
238
-        if($cmd instanceof Mailcode_Commands_Command)
238
+        if ($cmd instanceof Mailcode_Commands_Command)
239 239
         {
240 240
             self::$dummyCommands[$id] = $cmd;
241 241
             return $cmd;
Please login to merge, or discard this patch.
tools/extractPhoneCountries.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
     {
80 80
         $meta = $phoneNumberUtil->getMetadataForRegion($code);
81 81
         if (!$meta) {
82
-            die('No metadata for ' . $code);
82
+            die('No metadata for '.$code);
83 83
         }
84 84
 
85 85
         $exampleNumber = $phoneNumberUtil->getExampleNumber($code);
Please login to merge, or discard this patch.