Passed
Push — master ( d8dc61...dfdb64 )
by Sebastian
09:05
created
src/Mailcode/Commands/Highlighter.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $this->parts[] = $this->renderTag(array('command-name'), $this->command->getName());
54 54
         
55
-        if($this->command->hasType())
55
+        if ($this->command->hasType())
56 56
         {
57 57
             $this->parts[] = ' '.$this->renderTag(array('command-type'), $this->command->getType());
58 58
         }
59 59
         
60
-        if($this->command->requiresParameters())
60
+        if ($this->command->requiresParameters())
61 61
         {
62 62
             $this->parts[] = $this->renderTag(array('hyphen'), ':');
63 63
             $this->parts[] = '<wbr>';
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $params = $command->getParams();
70 70
         
71
-        if($params === null)
71
+        if ($params === null)
72 72
         {
73 73
             return;
74 74
         }
75 75
         
76 76
         $tokens = $params->getInfo()->getTokens();
77 77
 
78
-        if(!empty($tokens))
78
+        if (!empty($tokens))
79 79
         {
80 80
             $this->parts[] = ' ';
81 81
             $this->parts[] = '<span class="mailcode-params">';
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
         }
92 92
     }
93 93
     
94
-    protected function appendParamToken(Mailcode_Parser_Statement_Tokenizer_Token $token, ?Mailcode_Parser_Statement_Tokenizer_Token $previous=null) : void
94
+    protected function appendParamToken(Mailcode_Parser_Statement_Tokenizer_Token $token, ?Mailcode_Parser_Statement_Tokenizer_Token $previous = null) : void
95 95
     {
96
-        if($previous && $previous->hasSpacing()) {
96
+        if ($previous && $previous->hasSpacing()) {
97 97
             $this->parts[] = ' ';
98 98
         }
99 99
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     
103 103
     protected function appendLogicKeywords() : void
104 104
     {
105
-        if(!$this->command->supportsLogicKeywords())
105
+        if (!$this->command->supportsLogicKeywords())
106 106
         {
107 107
             return;
108 108
         }
109 109
         
110 110
         $keywords = $this->command->getLogicKeywords()->getKeywords();
111 111
         
112
-        foreach($keywords as $keyword)
112
+        foreach ($keywords as $keyword)
113 113
         {
114 114
             $this->appendLogicKeyword($keyword);
115 115
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         
122 122
         $type = $keyword->getType();
123 123
         
124
-        if(!empty($type))
124
+        if (!empty($type))
125 125
         {
126 126
             $this->parts[] = ' '.$this->renderTag(array('command-type'), $type);
127 127
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $parts = array();
142 142
         
143
-        foreach($classes as $class)
143
+        foreach ($classes as $class)
144 144
         {
145 145
             $parts[] = 'mailcode-'.$class;
146 146
         }
Please login to merge, or discard this patch.
tools/extractPhoneCountries.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use AppUtils\CSVHelper;
16 16
 use AppUtils\FileHelper;
17 17
 use libphonenumber\PhoneNumberFormat;
18
-use libphonenumber\PhoneNumberUtil;use Mailcode\Mailcode;use function AppLocalize\pts;
18
+use libphonenumber\PhoneNumberUtil; use Mailcode\Mailcode; use function AppLocalize\pts;
19 19
 
20 20
 require_once 'prepend.php';
21 21
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $meta = $phoneNumberUtil->getMetadataForRegion($code);
91 91
         if (!$meta) {
92
-            die('No metadata for ' . $code);
92
+            die('No metadata for '.$code);
93 93
         }
94 94
 
95 95
         $exampleNumber = $phoneNumberUtil->getExampleNumber($code);
Please login to merge, or discard this patch.
tools/syntax-highlighter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use Mailcode\Mailcode_Exception;
17 17
 use Mailcode\Mailcode_Translator_Exception;
18 18
 use function \AppLocalize\pt;
19
-use function \AppLocalize\pts;use function AppLocalize\t;
19
+use function \AppLocalize\pts; use function AppLocalize\t;
20 20
 
21 21
 require_once 'prepend.php';
22 22
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 $translated = '';
28 28
 $error = null;
29 29
 
30
-if($request->getBool('highlight'))
30
+if ($request->getBool('highlight'))
31 31
 {
32 32
     $commandsText = $request->getParam('mailcode');
33 33
 
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
         $error = $e->getMessage();
43 43
 
44 44
         $collection = $e->getCollection();
45
-        if($collection)
45
+        if ($collection)
46 46
         {
47 47
             $first = $collection->getFirstError();
48 48
             $error = $first->getMessage();
49 49
             $matched = $first->getMatchedText();
50
-            if(!empty($matched)) {
51
-                $error .= '<br>'. t('In command:').' <code>'.$matched.'</code>';
50
+            if (!empty($matched)) {
51
+                $error .= '<br>'.t('In command:').' <code>'.$matched.'</code>';
52 52
             }
53 53
         }
54 54
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         <p></p><br>
93 93
         <h2><?php pt('Highlighted commands') ?></h2>
94 94
         <?php
95
-            if(empty($commandsText))
95
+            if (empty($commandsText))
96 96
             {
97 97
                 ?>
98 98
                     <div class="alert alert-info">
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                     </div>
101 101
                 <?php
102 102
             }
103
-            else if($error)
103
+            else if ($error)
104 104
             {
105 105
                 ?>
106 106
                     <div class="alert alert-danger">
Please login to merge, or discard this patch.
src/Mailcode/Variables/Variable.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     private ?Mailcode_Commands_Command $command;
74 74
 
75
-    public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null)
75
+    public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null)
76 76
     {
77 77
         $this->path = $path;
78 78
         $this->name = $name;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     
96 96
     public function getFullName() : string
97 97
     {
98
-        if(empty($this->path))
98
+        if (empty($this->path))
99 99
         {
100 100
             return dollarize($this->name);
101 101
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getUniqueName() : string
115 115
     {
116
-        if(isset($this->command))
116
+        if (isset($this->command))
117 117
         {
118 118
             return $this->getFullName().'/'.$this->command->getHash();
119 119
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     
139 139
     public function getHash() : string
140 140
     {
141
-        if(empty($this->hash))
141
+        if (empty($this->hash))
142 142
         {
143 143
             $this->hash = md5($this->matchedText);
144 144
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function getValidationResult() : OperationResult
159 159
     {
160
-        if(isset($this->validationResult))
160
+        if (isset($this->validationResult))
161 161
         {
162 162
             return $this->validationResult;
163 163
         }
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
     protected function validate(OperationResult $result) : void
173 173
     {
174
-        foreach($this->validations as $validation)
174
+        foreach ($this->validations as $validation)
175 175
         {
176 176
             $method = 'validate_'.$validation;
177 177
             
178
-            if(!method_exists($this, $method))
178
+            if (!method_exists($this, $method))
179 179
             {
180 180
                 throw new Mailcode_Exception(
181 181
                     'Unknown validation method',
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     
226 226
     protected function validateNumber(string $value, int $errorCode) : void
227 227
     {
228
-        if(empty($value) || !is_numeric($value[0]))
228
+        if (empty($value) || !is_numeric($value[0]))
229 229
         {
230 230
             return;
231 231
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     protected function validateUnderscore(string $value, int $errorCode) : void
244 244
     {
245 245
         // allow empty paths
246
-        if(empty($value))
246
+        if (empty($value))
247 247
         {
248 248
             return;
249 249
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $length = strlen($value);
252 252
         
253 253
         // trimming underscores does not change the length: no underscores at start or end of string.
254
-        if(strlen(trim($value, '_')) === $length)
254
+        if (strlen(trim($value, '_')) === $length)
255 255
         {
256 256
             return;
257 257
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/DecryptTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
             ->getInfo()
35 35
             ->getTokenByParamName(DecryptInterface::PARAMETER_NAME);
36 36
 
37
-        if($token === null) {
37
+        if ($token === null) {
38 38
             return;
39 39
         }
40 40
 
41 41
         if (!$token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) {
42 42
             $this->validationResult->makeError(
43
-                t('Invalid decryption key token:') . ' ' . t('Expected a string.'),
43
+                t('Invalid decryption key token:').' '.t('Expected a string.'),
44 44
                 DecryptInterface::VALIDATION_DECRYPT_CODE_WRONG_TYPE
45 45
             );
46 46
         }
@@ -56,20 +56,20 @@  discard block
 block discarded – undo
56 56
     public function getDecryptionKeyName() : string
57 57
     {
58 58
         $key = $this->getDecryptionKeyToken();
59
-        if($key === null) {
59
+        if ($key === null) {
60 60
             return '';
61 61
         }
62 62
 
63 63
         $keyName = $key->getText();
64 64
 
65
-        if(empty($keyName)) {
65
+        if (empty($keyName)) {
66 66
             $keyName = (string)DecryptSettings::getDefaultKeyName();
67 67
         }
68 68
 
69 69
         return $keyName;
70 70
     }
71 71
 
72
-    public function enableDecryption(string $keyName=DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self
72
+    public function enableDecryption(string $keyName = DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self
73 73
     {
74 74
         $this->decryptionKeyToken = $this
75 75
             ->requireParams()
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function disableDecryption() : self
83 83
     {
84
-        if(isset($this->decryptionKeyToken)) {
84
+        if (isset($this->decryptionKeyToken)) {
85 85
             $this
86 86
                 ->requireParams()
87 87
                 ->getInfo()
Please login to merge, or discard this patch.
src/Mailcode/Interfaces/Commands/Validation/DecryptInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
      */
41 41
     public function getDecryptionKeyToken(): ?Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral;
42 42
 
43
-    public function enableDecryption(string $keyName=DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self;
43
+    public function enableDecryption(string $keyName = DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self;
44 44
 
45 45
     public function disableDecryption() : self;
46 46
     public function isDecryptionEnabled() : bool;
Please login to merge, or discard this patch.
src/Mailcode/Factory/Instantiator.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Mailcode_Factory_Instantiator
24 24
 {
25
-    public function buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase
25
+    public function buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase
26 26
     {
27 27
         $stringType = $type;
28 28
         
29
-        if(!empty($type))
29
+        if (!empty($type))
30 30
         {
31 31
             $stringType = ' '.$type;
32 32
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         
46 46
         $this->checkCommand($command);
47 47
         
48
-        if($command instanceof Mailcode_Commands_IfBase)
48
+        if ($command instanceof Mailcode_Commands_IfBase)
49 49
         {
50 50
             return $command;
51 51
         }
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
         throw $this->exceptionUnexpectedType('IfBase', $command);
54 54
     }
55 55
     
56
-    public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_IfBase
56
+    public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false, bool $insensitive = false) : Mailcode_Commands_IfBase
57 57
     {
58 58
         $variable = $this->filterVariableName($variable);
59 59
 
60
-        if($insensitive)
60
+        if ($insensitive)
61 61
         {
62 62
             $value = mb_strtolower($value);
63 63
         }
64 64
 
65
-        if($quoteValue)
65
+        if ($quoteValue)
66 66
         {
67 67
             $value = $this->quoteString($value);
68 68
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $value
75 75
         );
76 76
 
77
-        if($insensitive)
77
+        if ($insensitive)
78 78
         {
79 79
             $condition .= ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE;
80 80
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return Mailcode_Commands_IfBase
103 103
      * @throws Mailcode_Factory_Exception
104 104
      */
105
-    public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false, string $containsType='contains') : Mailcode_Commands_IfBase
105
+    public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false, string $containsType = 'contains') : Mailcode_Commands_IfBase
106 106
     {
107 107
         $condition = sprintf(
108 108
             '%s%s"%s"',
@@ -114,23 +114,23 @@  discard block
 block discarded – undo
114 114
         return $this->buildIf($ifType, $condition, $containsType);
115 115
     }
116 116
 
117
-    private function renderListKeywords(bool $caseInsensitive=false, bool $regexEnabled=false) : string
117
+    private function renderListKeywords(bool $caseInsensitive = false, bool $regexEnabled = false) : string
118 118
     {
119 119
         $keywords = array();
120 120
 
121
-        if($caseInsensitive)
121
+        if ($caseInsensitive)
122 122
         {
123 123
             $keywords[] = Mailcode_Commands_Keywords::TYPE_INSENSITIVE;
124 124
         }
125 125
 
126
-        if($regexEnabled)
126
+        if ($regexEnabled)
127 127
         {
128 128
             $keywords[] = Mailcode_Commands_Keywords::TYPE_REGEX;
129 129
         }
130 130
 
131 131
         $keywordsString = '';
132 132
 
133
-        if(!empty($keywords))
133
+        if (!empty($keywords))
134 134
         {
135 135
             $keywordsString = ' '.implode(' ', $keywords);
136 136
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      * @return Mailcode_Commands_IfBase
148 148
      * @throws Mailcode_Factory_Exception
149 149
      */
150
-    public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_IfBase
150
+    public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false) : Mailcode_Commands_IfBase
151 151
     {
152 152
         return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'not-contains');
153 153
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @return Mailcode_Commands_IfBase
163 163
      * @throws Mailcode_Factory_Exception
164 164
      */
165
-    public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false, string $containsType='list-contains') : Mailcode_Commands_IfBase
165
+    public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false, string $containsType = 'list-contains') : Mailcode_Commands_IfBase
166 166
     {
167 167
         return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, $containsType);
168 168
     }
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
      * @return Mailcode_Commands_IfBase
177 177
      * @throws Mailcode_Factory_Exception
178 178
      */
179
-    public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_IfBase
179
+    public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false) : Mailcode_Commands_IfBase
180 180
     {
181 181
         return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'list-not-contains');
182 182
     }
183 183
 
184
-    public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
184
+    public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
185 185
     {
186 186
         return $this->buildIfSearch($ifType, 'begins-with', $variable, $search, $caseInsensitive);
187 187
     }
188 188
     
189
-    public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
189
+    public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
190 190
     {
191 191
         return $this->buildIfSearch($ifType, 'ends-with', $variable, $search, $caseInsensitive);
192 192
     }
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
         );
237 237
     }
238 238
 
239
-    private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
239
+    private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
240 240
     {
241 241
         $keyword = ' ';
242 242
         
243
-        if($caseInsensitive)
243
+        if ($caseInsensitive)
244 244
         {
245 245
             $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE;
246 246
         }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function checkCommand(Mailcode_Commands_Command $command) : void
281 281
     {
282
-        if($command->isValid())
282
+        if ($command->isValid())
283 283
         {
284 284
             return;
285 285
         }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function setEncoding(Mailcode_Commands_Command $cmd, string $urlEncoding) : void
315 315
     {
316
-        if($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLEncode)
316
+        if ($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLEncode)
317 317
         {
318 318
             $cmd->setURLEncoding(false);
319 319
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
             }
324 324
         }
325 325
 
326
-        if($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLDecode)
326
+        if ($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLDecode)
327 327
         {
328 328
             $cmd->setURLDecoding(false);
329 329
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function quoteString(string $string) : string
344 344
     {
345
-        if(substr($string, 0, 1) === '"' && substr($string, -1, 1) === '"') {
345
+        if (substr($string, 0, 1) === '"' && substr($string, -1, 1) === '"') {
346 346
             return $string;
347 347
         }
348 348
 
Please login to merge, or discard this patch.
src/Mailcode/Translator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function createSyntax(string $name) : Syntax
38 38
     {
39
-        if($this->syntaxExists($name))
39
+        if ($this->syntaxExists($name))
40 40
         {
41 41
             return new Syntax($name);
42 42
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $names = $this->getSyntaxNames();
74 74
         $result = array();
75 75
 
76
-        foreach($names as $name)
76
+        foreach ($names as $name)
77 77
         {
78 78
             $result[] = $this->createSyntax($name);
79 79
         }
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowSnippetTranslation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     {
30 30
         $varName = undollarize($command->getVariableName());
31 31
 
32
-        if($command->isHTMLEnabled())
32
+        if ($command->isHTMLEnabled())
33 33
         {
34 34
             $statement = sprintf(
35 35
                 '%s.replaceAll($esc.newline, "<br/>")',
Please login to merge, or discard this patch.