Passed
Push — master ( 7822c6...0f91e9 )
by Sebastian
03:25
created
src/Mailcode/Traits/Commands/Validation/QueryParamsTrait.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $params = $this->collectParams();
54 54
         $result = array();
55 55
 
56
-        foreach($params as $param)
56
+        foreach ($params as $param)
57 57
         {
58 58
             $result[$param->getName()] = $param->getValue();
59 59
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $params = $this->collectParams();
70 70
         $result = array();
71 71
 
72
-        foreach($params as $param)
72
+        foreach ($params as $param)
73 73
         {
74 74
             $result[] = $param->getToken();
75 75
         }
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 
90 90
         $result = array();
91 91
 
92
-        foreach($literals as $literal)
92
+        foreach ($literals as $literal)
93 93
         {
94 94
             $text = $literal->getText();
95 95
 
96
-            if(strpos($text, '=') !== false)
96
+            if (strpos($text, '=') !== false)
97 97
             {
98 98
                 $param = new QueryParam($literal);
99 99
                 $result[$param->getName()] = $param;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     {
108 108
         $params = $this->collectParams();
109 109
 
110
-        if(isset($params[$name]))
110
+        if (isset($params[$name]))
111 111
         {
112 112
             return $params[$name]->getValue();
113 113
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $params = $this->collectParams();
128 128
 
129
-        if(isset($params[$name]))
129
+        if (isset($params[$name]))
130 130
         {
131 131
             $params[$name]->setValue($value);
132 132
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $params = $this->collectParams();
151 151
 
152
-        if(isset($params[$name]))
152
+        if (isset($params[$name]))
153 153
         {
154 154
             $this->requireParams()
155 155
                 ->getInfo()
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
         if(isset($params[$name]))
130 130
         {
131 131
             $params[$name]->setValue($value);
132
-        }
133
-        else
132
+        } else
134 133
         {
135 134
             $this->addParam($name, $value);
136 135
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/TrackingIDTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $token = $this->getTrackingIDToken();
47 47
 
48
-        if($token === null)
48
+        if ($token === null)
49 49
         {
50 50
             return '';
51 51
         }
52 52
 
53 53
         $trackingID = $token->getText();
54 54
 
55
-        if(empty($trackingID))
55
+        if (empty($trackingID))
56 56
         {
57 57
             $trackingID = AutoTrackingID::generate($this);
58 58
             $token->setText($trackingID);
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 
71 71
     private function initTrackingToken() : void
72 72
     {
73
-        if(!$this->isTrackingEnabled())
73
+        if (!$this->isTrackingEnabled())
74 74
         {
75 75
             $this->clearTrackingToken();
76 76
             return;
77 77
         }
78 78
 
79
-        if(isset($this->trackingIDToken))
79
+        if (isset($this->trackingIDToken))
80 80
         {
81 81
             return;
82 82
         }
83 83
 
84 84
         $token = $this->detectToken();
85
-        if($token === null)
85
+        if ($token === null)
86 86
         {
87 87
             $token = $this->requireParams()
88 88
                 ->getInfo()
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $this->trackingIDToken = null;
98 98
 
99 99
         $token = $this->detectToken();
100
-        if($token !== null)
100
+        if ($token !== null)
101 101
         {
102 102
             $this->requireParams()
103 103
                 ->getInfo()
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     {
110 110
         $token = $this->getTrackingIDToken();
111 111
 
112
-        if($token !== null)
112
+        if ($token !== null)
113 113
         {
114 114
             $token->setText($trackingID);
115 115
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             ->getInfo()
131 131
             ->getStringLiterals();
132 132
 
133
-        if(empty($literals))
133
+        if (empty($literals))
134 134
         {
135 135
             return null;
136 136
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         $id = $trackingID->getText();
141 141
 
142
-        if(strpos($id, '=') === false)
142
+        if (strpos($id, '=') === false)
143 143
         {
144 144
             return $trackingID;
145 145
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
         Mailcode_Parser_Statement_Tokenizer_Process_ExtractTokens::class
43 43
     );
44 44
     
45
-   /**
46
-    * @var Mailcode_Parser_Statement
47
-    */
45
+    /**
46
+     * @var Mailcode_Parser_Statement
47
+     */
48 48
     protected Mailcode_Parser_Statement $statement;
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected string $tokenized = '';
54 54
     
55 55
     /**
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
      */
58 58
     protected array $tokensOrdered = array();
59 59
     
60
-   /**
61
-    * @var string[]
62
-    */
60
+    /**
61
+     * @var string[]
62
+     */
63 63
     protected static array $ids = array();
64 64
 
65 65
     /**
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
         return $this->statement->getSourceCommand();
80 80
     }
81 81
 
82
-   /**
83
-    * Retrieves all tokens detected in the statement string, in 
84
-    * the order they were found.
85
-    * 
86
-    * @return Mailcode_Parser_Statement_Tokenizer_Token[]
87
-    */
82
+    /**
83
+     * Retrieves all tokens detected in the statement string, in 
84
+     * the order they were found.
85
+     * 
86
+     * @return Mailcode_Parser_Statement_Tokenizer_Token[]
87
+     */
88 88
     public function getTokens() : array
89 89
     {
90 90
         return $this->tokensOrdered;
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
         return !empty($this->tokensOrdered);
96 96
     }
97 97
     
98
-   /**
99
-    * Whether there were any unknown tokens in the statement.
100
-    * 
101
-    * @return bool
102
-    */
98
+    /**
99
+     * Whether there were any unknown tokens in the statement.
100
+     * 
101
+     * @return bool
102
+     */
103 103
     public function hasUnknown() : bool
104 104
     {
105 105
         $unknown = $this->getUnknown();
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         return !empty($unknown);
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves all unknown content tokens, if any.
112
-    * 
113
-    * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
114
-    */
110
+    /**
111
+     * Retrieves all unknown content tokens, if any.
112
+     * 
113
+     * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
114
+     */
115 115
     public function getUnknown() : array
116 116
     {
117 117
         $result = array();
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
         return $this;
348 348
     }
349 349
     
350
-   /**
351
-    * Generates a unique alphabet-based ID without numbers
352
-    * to use as token name, to avoid conflicts with the
353
-    * numbers detection.
354
-    *
355
-    * @return string
356
-    */
350
+    /**
351
+     * Generates a unique alphabet-based ID without numbers
352
+     * to use as token name, to avoid conflicts with the
353
+     * numbers detection.
354
+     *
355
+     * @return string
356
+     */
357 357
     protected function generateID() : string
358 358
     {
359 359
         static $alphas;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $result = array();
118 118
         
119
-        foreach($this->tokensOrdered as $token)
119
+        foreach ($this->tokensOrdered as $token)
120 120
         {
121
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
121
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
122 122
             {
123 123
                 $result[] = $token;
124 124
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $unknown = $this->getUnknown();
133 133
         
134
-        if(!empty($unknown))
134
+        if (!empty($unknown))
135 135
         {
136 136
             return array_shift($unknown);
137 137
         }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $parts = array();
145 145
 
146
-        foreach($this->tokensOrdered as $token)
146
+        foreach ($this->tokensOrdered as $token)
147 147
         {
148 148
             $string = $token->getNormalized();
149 149
             
150
-            if($string !== '')
150
+            if ($string !== '')
151 151
             {
152 152
                 $parts[] = $string;
153 153
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         $statement = trim($statement);
173 173
         $tokens = array();
174 174
 
175
-        foreach($this->tokenClasses as $tokenClass)
175
+        foreach ($this->tokenClasses as $tokenClass)
176 176
         {
177 177
             $processor = $this->createProcessor($tokenClass, $statement, $tokens);
178 178
             $processor->process();
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     {
197 197
         $instance = new $className($this, $statement, $tokens);
198 198
 
199
-        if($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process)
199
+        if ($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process)
200 200
         {
201 201
             return $instance;
202 202
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * @param mixed $subject
218 218
      * @return Mailcode_Parser_Statement_Tokenizer_Token
219 219
      */
220
-    public function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token
220
+    public function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token
221 221
     {
222 222
         $tokenID = $this->generateID();
223 223
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
         $token = new $class($tokenID, $matchedText, $subject, $this->getSourceCommand());
227 227
 
228
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token)
228
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token)
229 229
         {
230 230
             return $token;
231 231
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
         $token = $this->createToken('Keyword', $name);
248 248
 
249
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
249
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
250 250
         {
251 251
             return $token;
252 252
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     {
272 272
         $token = $this->createToken('StringLiteral', SpecialChars::encodeAll($text));
273 273
 
274
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
274
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
275 275
         {
276 276
             return $token;
277 277
         }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
         foreach ($this->tokensOrdered as $checkToken)
310 310
         {
311
-            if($checkToken->getID() !== $tokenID)
311
+            if ($checkToken->getID() !== $tokenID)
312 312
             {
313 313
                 $keep[] = $checkToken;
314 314
             }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     {
359 359
         static $alphas;
360 360
 
361
-        if(!isset($alphas))
361
+        if (!isset($alphas))
362 362
         {
363 363
             $alphas = range('A', 'Z');
364 364
         }
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 
368 368
         $result = '';
369 369
 
370
-        for($i=0; $i < $amount; $i++)
370
+        for ($i = 0; $i < $amount; $i++)
371 371
         {
372 372
             $result .= $alphas[array_rand($alphas)];
373 373
         }
374 374
 
375
-        if(!in_array($result, self::$ids))
375
+        if (!in_array($result, self::$ids))
376 376
         {
377 377
             self::$ids[] = $result;
378 378
             return $result;
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowNumber.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
     public const VALIDATION_INVALID_DECIMAL_SEPARATOR = 72209;
31 31
     public const VALIDATION_SEPARATORS_SAME_CHARACTER = 72210;
32 32
     
33
-   /**
34
-    * The default number format string.
35
-    * @var string
36
-    */
33
+    /**
34
+     * The default number format string.
35
+     * @var string
36
+     */
37 37
     private string $formatString = Mailcode_Number_Info::DEFAULT_FORMAT;
38 38
 
39 39
     /**
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
 
63 63
     protected function validateSyntax_check_format() : void
64 64
     {
65
-         $tokens = $this->requireParams()
66
-             ->getInfo()
67
-             ->getStringLiterals();
65
+            $tokens = $this->requireParams()
66
+                ->getInfo()
67
+                ->getStringLiterals();
68 68
          
69
-         // no format specified? Use the default one.
70
-         if(empty($tokens))
71
-         {
72
-             return;
73
-         }
74
-
75
-         $token = array_pop($tokens);
76
-         $this->parseFormatString($token->getText());
69
+            // no format specified? Use the default one.
70
+            if(empty($tokens))
71
+            {
72
+                return;
73
+            }
74
+
75
+            $token = array_pop($tokens);
76
+            $this->parseFormatString($token->getText());
77 77
     }
78 78
 
79 79
     protected function validateSyntax_absolute() : void
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         );
109 109
     }
110 110
     
111
-   /**
112
-    * Retrieves the format string used to format the number.
113
-    * 
114
-    * @return string
115
-    */
111
+    /**
112
+     * Retrieves the format string used to format the number.
113
+     * 
114
+     * @return string
115
+     */
116 116
     public function getFormatString() : string
117 117
     {
118 118
         return $this->formatString;
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 
134 134
         if($absolute === true && !isset($this->absoluteKeyword))
135 135
         {
136
-             $this->requireParams()
137
-                 ->getInfo()
138
-                 ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE);
136
+                $this->requireParams()
137
+                    ->getInfo()
138
+                    ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE);
139 139
 
140
-             $this->validateSyntax_absolute();
140
+                $this->validateSyntax_absolute();
141 141
         }
142 142
 
143 143
         return $this;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
              ->getStringLiterals();
68 68
          
69 69
          // no format specified? Use the default one.
70
-         if(empty($tokens))
70
+         if (empty($tokens))
71 71
          {
72 72
              return;
73 73
          }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
             ->getInfo()
83 83
             ->getKeywords();
84 84
 
85
-        foreach($keywords as $keyword)
85
+        foreach ($keywords as $keyword)
86 86
         {
87
-            if($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE)
87
+            if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE)
88 88
             {
89 89
                 $this->absoluteKeyword = $keyword;
90 90
                 break;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $result = new Mailcode_Number_Info($format);
98 98
 
99
-        if($result->isValid())
99
+        if ($result->isValid())
100 100
         {
101 101
             $this->formatString = $format;
102 102
             return;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function setAbsolute(bool $absolute) : Mailcode_Commands_Command_ShowNumber
127 127
     {
128
-        if($absolute === false && isset($this->absoluteKeyword))
128
+        if ($absolute === false && isset($this->absoluteKeyword))
129 129
         {
130 130
             $this->requireParams()->getInfo()->removeKeyword($this->absoluteKeyword->getKeyword());
131 131
             $this->absoluteKeyword = null;
132 132
         }
133 133
 
134
-        if($absolute === true && !isset($this->absoluteKeyword))
134
+        if ($absolute === true && !isset($this->absoluteKeyword))
135 135
         {
136 136
              $this->requireParams()
137 137
                  ->getInfo()
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowDate.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Mailcode_Commands_Command_ShowDate extends Mailcode_Commands_ShowBase
22 22
 {
23
-   /**
24
-    * The date format string.
25
-    * @var string
26
-    */
23
+    /**
24
+     * The date format string.
25
+     * @var string
26
+     */
27 27
     private string $formatString;
28 28
     
29
-   /**
30
-    * @var Mailcode_Date_FormatInfo
31
-    */
29
+    /**
30
+     * @var Mailcode_Date_FormatInfo
31
+     */
32 32
     private Mailcode_Date_FormatInfo $formatInfo;
33 33
 
34 34
     public function getName() : string
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
         );
90 90
     }
91 91
     
92
-   /**
93
-    * Retrieves the format string used to format the date.
94
-    * 
95
-    * @return string A PHP compatible date format string.
96
-    */
92
+    /**
93
+     * Retrieves the format string used to format the date.
94
+     * 
95
+     * @return string A PHP compatible date format string.
96
+     */
97 97
     public function getFormatString() : string
98 98
     {
99 99
         return $this->formatString;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             ->getStringLiterals();
65 65
 
66 66
         // no format specified? Use the default one.
67
-        if(empty($tokens))
67
+        if (empty($tokens))
68 68
         {
69 69
             return;
70 70
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         $result = $this->formatInfo->validateFormat($format);
79 79
 
80
-        if($result->isValid())
80
+        if ($result->isValid())
81 81
         {
82 82
             $this->formatString = $format;
83 83
             return;
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $tokens = $this->requireParams()->getInfo()->getTokens();
59 59
         $allowed = $this->resolveActiveTokens();
60 60
 
61
-        if(count($tokens) > count($allowed))
61
+        if (count($tokens) > count($allowed))
62 62
         {
63 63
             $this->validationResult->makeError(
64 64
                 t('Unknown parameters found:').' '.
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 
82 82
         $encodings = $this->getSupportedEncodings();
83 83
 
84
-        foreach($encodings as $keyword)
84
+        foreach ($encodings as $keyword)
85 85
         {
86 86
             $token = $this->getEncodingToken($keyword);
87
-            if($token)
87
+            if ($token)
88 88
             {
89 89
                 $allowed[] = $token;
90 90
             }
Please login to merge, or discard this patch.