@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $token = $this->getTrackingIDToken(); |
| 47 | 47 | |
| 48 | - if($token === null) |
|
| 48 | + if ($token === null) |
|
| 49 | 49 | { |
| 50 | 50 | return ''; |
| 51 | 51 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private function filterTrackingID(string $trackingID) : string |
| 60 | 60 | { |
| 61 | - if(empty($trackingID)) |
|
| 61 | + if (empty($trackingID)) |
|
| 62 | 62 | { |
| 63 | 63 | return AutoTrackingID::generate($this); |
| 64 | 64 | } |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | private function initTrackingToken() : void |
| 77 | 77 | { |
| 78 | - if(!$this->isTrackingEnabled()) |
|
| 78 | + if (!$this->isTrackingEnabled()) |
|
| 79 | 79 | { |
| 80 | 80 | $this->clearTrackingIDToken(); |
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(isset($this->trackingIDToken)) |
|
| 84 | + if (isset($this->trackingIDToken)) |
|
| 85 | 85 | { |
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $token = $this->detectToken(); |
| 90 | - if($token === null) |
|
| 90 | + if ($token === null) |
|
| 91 | 91 | { |
| 92 | 92 | $token = $this->requireParams() |
| 93 | 93 | ->getInfo() |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $this->trackingIDToken = null; |
| 103 | 103 | |
| 104 | 104 | $token = $this->detectToken(); |
| 105 | - if($token !== null) |
|
| 105 | + if ($token !== null) |
|
| 106 | 106 | { |
| 107 | 107 | $this->requireParams() |
| 108 | 108 | ->getInfo() |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $token = $this->getTrackingIDToken(); |
| 116 | 116 | |
| 117 | - if($token !== null) |
|
| 117 | + if ($token !== null) |
|
| 118 | 118 | { |
| 119 | 119 | $token->setText($this->filterTrackingID($trackingID)); |
| 120 | 120 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | ->getInfo() |
| 129 | 129 | ->getStringLiterals(); |
| 130 | 130 | |
| 131 | - if(empty($literals)) |
|
| 131 | + if (empty($literals)) |
|
| 132 | 132 | { |
| 133 | 133 | return null; |
| 134 | 134 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $id = $trackingID->getText(); |
| 139 | 139 | |
| 140 | - if(strpos($id, '=') === false) |
|
| 140 | + if (strpos($id, '=') === false) |
|
| 141 | 141 | { |
| 142 | 142 | return $trackingID; |
| 143 | 143 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | 'ShowVariable', |
| 36 | 36 | '', |
| 37 | 37 | $variableName, |
| 38 | - '{showvar:' . $variableName . '}' |
|
| 38 | + '{showvar:'.$variableName.'}' |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | $this->instantiator->checkCommand($cmd); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $cmd = $this->commands->createCommand( |
| 52 | 52 | 'ShowDate', |
| 53 | 53 | '', |
| 54 | - $variableName . $format . $timezone, |
|
| 54 | + $variableName.$format.$timezone, |
|
| 55 | 55 | sprintf( |
| 56 | 56 | '{showdate: %s%s%s}', |
| 57 | 57 | $variableName, |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | return $string; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return '"' . str_replace('"', '\"', $string) . '"'; |
|
| 78 | + return '"'.str_replace('"', '\"', $string).'"'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | if (!$this->loopVar || !$this->keyword || !$this->sourceVar) { |
| 148 | 148 | $this->validationResult->makeError( |
| 149 | - t('Not a valid for loop.') . ' ' . t('Is the %1$s keyword missing?', 'in:'), |
|
| 149 | + t('Not a valid for loop.').' '.t('Is the %1$s keyword missing?', 'in:'), |
|
| 150 | 150 | self::VALIDATION_INVALID_FOR_STATEMENT |
| 151 | 151 | ); |
| 152 | 152 | |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $this->validationResult->makeError( |
| 194 | - t('The source variable is not a list variable:') . ' ' . |
|
| 195 | - t('Expected a variable without dot, like %1$s.', '<code>$' . t('LIST') . '</code>'), |
|
| 194 | + t('The source variable is not a list variable:').' '. |
|
| 195 | + t('Expected a variable without dot, like %1$s.', '<code>$'.t('LIST').'</code>'), |
|
| 196 | 196 | self::VALIDATION_VARIABLE_NAME_WITH_DOT |
| 197 | 197 | ); |
| 198 | 198 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // allowed ones. |
| 125 | 125 | if (!in_array($sign, $allowed)) { |
| 126 | 126 | $this->validationResult->makeError( |
| 127 | - t('The %1$s sign is not allowed in this command.', '<code>' . $sign . '</code>'), |
|
| 127 | + t('The %1$s sign is not allowed in this command.', '<code>'.$sign.'</code>'), |
|
| 128 | 128 | Mailcode_Commands_CommonConstants::VALIDATION_INVALID_OPERAND |
| 129 | 129 | ); |
| 130 | 130 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | throw new Mailcode_Exception( |
| 152 | 152 | 'No variable found.', |
| 153 | - 'Statement does not start with a variable: [' . $this->paramsString . ']', |
|
| 153 | + 'Statement does not start with a variable: ['.$this->paramsString.']', |
|
| 154 | 154 | Mailcode_Commands_CommonConstants::ERROR_NO_VARIABLE_AVAILABLE |
| 155 | 155 | ); |
| 156 | 156 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | public function __construct(string $message, ?string $details = null, $code = null, $previous = null) |
| 24 | 24 | { |
| 25 | - if(defined('TESTS_ROOT') && !empty($details)) { |
|
| 25 | + if (defined('TESTS_ROOT') && !empty($details)) { |
|
| 26 | 26 | $message .= PHP_EOL. |
| 27 | 27 | 'Details:'.PHP_EOL. |
| 28 | 28 | $details; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | $vars = Mailcode::create()->findVariables($this->tokenized, $this->tokenizer->getSourceCommand())->getGroupedByHash(); |
| 12 | 12 | |
| 13 | 13 | $names = array(); |
| 14 | - foreach($vars as $var) |
|
| 14 | + foreach ($vars as $var) |
|
| 15 | 15 | { |
| 16 | 16 | $names[$var->getMatchedText()] = $var; |
| 17 | 17 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | return strlen($b) - strlen($a); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - foreach($names as $name => $var) |
|
| 26 | + foreach ($names as $name => $var) |
|
| 27 | 27 | { |
| 28 | 28 | $this->registerToken('Variable', $name, $var); |
| 29 | 29 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $fullName = $this->fixName($fullName); |
| 64 | 64 | |
| 65 | - foreach($this->variables as $variable) |
|
| 65 | + foreach ($this->variables as $variable) |
|
| 66 | 66 | { |
| 67 | - if($variable->getFullName() === $fullName) |
|
| 67 | + if ($variable->getFullName() === $fullName) |
|
| 68 | 68 | { |
| 69 | 69 | return true; |
| 70 | 70 | } |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $collection = new Mailcode_Variables_Collection_Regular(); |
| 89 | 89 | |
| 90 | - foreach($this->variables as $variable) |
|
| 90 | + foreach ($this->variables as $variable) |
|
| 91 | 91 | { |
| 92 | - if($variable->getFullName() === $fullName) |
|
| 92 | + if ($variable->getFullName() === $fullName) |
|
| 93 | 93 | { |
| 94 | 94 | $collection->add($variable); |
| 95 | 95 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $entries = array(); |
| 121 | 121 | |
| 122 | - foreach($this->variables as $variable) |
|
| 122 | + foreach ($this->variables as $variable) |
|
| 123 | 123 | { |
| 124 | 124 | $entries[$variable->getHash()] = $variable; |
| 125 | 125 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $entries = array(); |
| 138 | 138 | |
| 139 | - foreach($this->variables as $variable) |
|
| 139 | + foreach ($this->variables as $variable) |
|
| 140 | 140 | { |
| 141 | 141 | $entries[$variable->getFullName()] = $variable; |
| 142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $entries = array(); |
| 157 | 157 | |
| 158 | - foreach($this->variables as $variable) |
|
| 158 | + foreach ($this->variables as $variable) |
|
| 159 | 159 | { |
| 160 | 160 | $entries[$variable->getUniqueName()] = $variable; |
| 161 | 161 | } |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $result = array(); |
| 182 | 182 | |
| 183 | - foreach($this->variables as $variable) |
|
| 183 | + foreach ($this->variables as $variable) |
|
| 184 | 184 | { |
| 185 | 185 | $name = $variable->getFullName(); |
| 186 | 186 | |
| 187 | - if(!in_array($name, $result)) |
|
| 187 | + if (!in_array($name, $result)) |
|
| 188 | 188 | { |
| 189 | 189 | $result[] = $name; |
| 190 | 190 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $variables = $collection->getGroupedByHash(); |
| 225 | 225 | |
| 226 | - foreach($variables as $variable) |
|
| 226 | + foreach ($variables as $variable) |
|
| 227 | 227 | { |
| 228 | 228 | $this->add($variable); |
| 229 | 229 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | $variables = $this->getAll(); |
| 237 | 237 | |
| 238 | - if(!empty($variables)) |
|
| 238 | + if (!empty($variables)) |
|
| 239 | 239 | { |
| 240 | 240 | return array_shift($variables); |
| 241 | 241 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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', |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | protected function validateNumber(string $value, int $errorCode) : void |
| 222 | 222 | { |
| 223 | - if(!is_numeric(substr($value, 0, 1))) |
|
| 223 | + if (!is_numeric(substr($value, 0, 1))) |
|
| 224 | 224 | { |
| 225 | 225 | return; |
| 226 | 226 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | protected function validateUnderscore(string $value, int $errorCode) : void |
| 239 | 239 | { |
| 240 | 240 | // allow empty paths |
| 241 | - if(empty($value)) |
|
| 241 | + if (empty($value)) |
|
| 242 | 242 | { |
| 243 | 243 | return; |
| 244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $length = strlen($value); |
| 247 | 247 | |
| 248 | 248 | // trimming underscores does not change the length: no underscores at start or end of string. |
| 249 | - if(strlen(trim($value, '_')) === $length) |
|
| 249 | + if (strlen(trim($value, '_')) === $length) |
|
| 250 | 250 | { |
| 251 | 251 | return; |
| 252 | 252 | } |