@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $pos = $this->getStartPosition(); |
55 | 55 | |
56 | - if(is_bool($pos)) |
|
56 | + if (is_bool($pos)) |
|
57 | 57 | { |
58 | 58 | return ''; |
59 | 59 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | { |
76 | 76 | $tagNames = $this->getParentTags(); |
77 | 77 | |
78 | - foreach($tagNames as $tagName) |
|
78 | + foreach ($tagNames as $tagName) |
|
79 | 79 | { |
80 | - if($this->formatter->isTagExcluded($tagName)) |
|
80 | + if ($this->formatter->isTagExcluded($tagName)) |
|
81 | 81 | { |
82 | 82 | return true; |
83 | 83 | } |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | // Create a stack of all direct parent tags of the command. |
100 | 100 | // Handles closing tags as well. |
101 | 101 | $stack = array(); |
102 | - foreach($tags[2] as $idx => $tagName) |
|
102 | + foreach ($tags[2] as $idx => $tagName) |
|
103 | 103 | { |
104 | 104 | $closing = $tags[1][$idx] === '/'; |
105 | 105 | |
106 | - if($closing) |
|
106 | + if ($closing) |
|
107 | 107 | { |
108 | 108 | array_pop($stack); |
109 | 109 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | // This check is easy: if the command is in the attribute |
130 | 130 | // of any of the tags, we will find the command marker in there. |
131 | - foreach($tags[3] as $attributes) |
|
131 | + foreach ($tags[3] as $attributes) |
|
132 | 132 | { |
133 | - if(strstr($attributes, self::COMMAND_MARKER)) |
|
133 | + if (strstr($attributes, self::COMMAND_MARKER)) |
|
134 | 134 | { |
135 | 135 | return true; |
136 | 136 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | private function getTagAncestry() : array |
149 | 149 | { |
150 | - if($this->ancestryChecked) |
|
150 | + if ($this->ancestryChecked) |
|
151 | 151 | { |
152 | 152 | return $this->tagAncestry; |
153 | 153 | } |
@@ -89,23 +89,23 @@ discard block |
||
89 | 89 | |
90 | 90 | $placeholderID = $this->placeholder->getID(); |
91 | 91 | |
92 | - foreach($placeholders as $placeholder) |
|
92 | + foreach ($placeholders as $placeholder) |
|
93 | 93 | { |
94 | - if($placeholder->getID() === $placeholderID) |
|
94 | + if ($placeholder->getID() === $placeholderID) |
|
95 | 95 | { |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $start = $this->subject->getSubstrPosition($placeholder->getReplacementText()); |
100 | 100 | |
101 | - if($start === false) |
|
101 | + if ($start === false) |
|
102 | 102 | { |
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $end = $start + $placeholder->getReplacementLength(); |
107 | 107 | |
108 | - if($position >= $start && $position <= $end) |
|
108 | + if ($position >= $start && $position <= $end) |
|
109 | 109 | { |
110 | 110 | return true; |
111 | 111 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $start = $this->getStartPosition(); |
123 | 123 | |
124 | - if($start !== false) |
|
124 | + if ($start !== false) |
|
125 | 125 | { |
126 | 126 | return $start + $this->placeholder->getReplacementLength(); |
127 | 127 | } |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | { |
152 | 152 | $needle = $this->placeholder->getReplacementText(); |
153 | 153 | |
154 | - if($this->subject->replaceSubstrings($needle, $replacementText)) |
|
154 | + if ($this->subject->replaceSubstrings($needle, $replacementText)) |
|
155 | 155 | { |
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Complain about missing placeholders only if we |
160 | 160 | // are not in partial mode. |
161 | - if(!$this->formatter->getFormatting()->isPartial()) |
|
161 | + if (!$this->formatter->getFormatting()->isPartial()) |
|
162 | 162 | { |
163 | 163 | throw new Mailcode_Exception( |
164 | 164 | 'Could not find the placeholder to replace', |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | public function format() : void |
175 | 175 | { |
176 | - if($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append))) |
|
176 | + if ($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append))) |
|
177 | 177 | { |
178 | 178 | $this->replaceWith(sprintf( |
179 | 179 | '%s%s%s', |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function setTemplate(string $template) : Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
62 | 62 | { |
63 | - if(substr_count($template, '%s') !== 1) |
|
63 | + if (substr_count($template, '%s') !== 1) |
|
64 | 64 | { |
65 | 65 | throw new Mailcode_Exception( |
66 | 66 | 'Invalid tag template', |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $parts = explode('%s', $this->getTemplate()); |
102 | 102 | $tag = array_shift($parts); |
103 | 103 | |
104 | - if($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
104 | + if ($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
105 | 105 | { |
106 | 106 | $tag = str_replace('__STYLES__', $this->getInlineStyles(), $tag); |
107 | 107 | } |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | $styles = ''; |
130 | 130 | $regex = '/\.'.self::DEFAULT_CLASS_NAME.'{([^}]+)}/'; |
131 | 131 | |
132 | - if(preg_match($regex, $this->getCSS(), $matches)) |
|
132 | + if (preg_match($regex, $this->getCSS(), $matches)) |
|
133 | 133 | { |
134 | 134 | $styles = $matches[1]; |
135 | 135 | } |
136 | 136 | |
137 | - if(empty($styles)) |
|
137 | + if (empty($styles)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Cannot extract styles.', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $file = MAILCODE_INSTALL_FOLDER.'/css/marked-variables.css'; |
192 | 192 | $path = realpath($file); |
193 | 193 | |
194 | - if($path !== false) |
|
194 | + if ($path !== false) |
|
195 | 195 | { |
196 | 196 | return $path; |
197 | 197 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $varName = ltrim($command->getVariableName(), '$'); |
57 | 57 | $javaFormat = $this->translateFormat($command->getFormatString()); |
58 | 58 | |
59 | - if(empty($internalFormat)) |
|
59 | + if (empty($internalFormat)) |
|
60 | 60 | { |
61 | 61 | $internalFormat = self::DEFAULT_INTERNAL_FORMAT; |
62 | 62 | } |
63 | 63 | |
64 | - if($command->isURLEncoded()) |
|
64 | + if ($command->isURLEncoded()) |
|
65 | 65 | { |
66 | 66 | return sprintf( |
67 | 67 | '${esc.url($date.format("%s", $date.toDate("%s", $%s)))}', |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $chars = ConvertHelper::string2array($formatString); |
85 | 85 | $result = array(); |
86 | 86 | |
87 | - foreach($chars as $char) |
|
87 | + foreach ($chars as $char) |
|
88 | 88 | { |
89 | - if(!isset($this->charTable[$char])) |
|
89 | + if (!isset($this->charTable[$char])) |
|
90 | 90 | { |
91 | 91 | throw new Mailcode_Translator_Exception( |
92 | 92 | 'Unknown date format string character', |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $locale |
41 | 41 | ); |
42 | 42 | |
43 | - if($command->isURLEncoded()) |
|
43 | + if ($command->isURLEncoded()) |
|
44 | 44 | { |
45 | 45 | return sprintf( |
46 | 46 | '${esc.url($%s)}', |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $dc = '_'; |
93 | 93 | } |
94 | 94 | |
95 | - $type = $th . $dc; |
|
95 | + $type = $th.$dc; |
|
96 | 96 | |
97 | 97 | if (isset($this->typeLocales[$type])) { |
98 | 98 | return $this->typeLocales[$type]; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | { |
106 | 106 | $result = '#'; |
107 | 107 | |
108 | - if($format->hasThousandsSeparator()) |
|
108 | + if ($format->hasThousandsSeparator()) |
|
109 | 109 | { |
110 | 110 | $result = '#,###'; |
111 | 111 | } |
112 | 112 | |
113 | - if($format->hasDecimals()) |
|
113 | + if ($format->hasDecimals()) |
|
114 | 114 | { |
115 | 115 | $result .= '.'.str_repeat('#', $format->getDecimals()); |
116 | 116 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $formatString A date format string, or empty string for default. |
48 | 48 | * @return Mailcode_Commands_Command_ShowDate |
49 | 49 | */ |
50 | - public static function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
50 | + public static function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
51 | 51 | { |
52 | 52 | return self::$commandSets->show()->showDate($variableName, $formatString); |
53 | 53 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param string $formatString A number format string, or empty string for default. |
61 | 61 | * @return Mailcode_Commands_Command_ShowNumber |
62 | 62 | */ |
63 | - public static function showNumber(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowNumber |
|
63 | + public static function showNumber(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowNumber |
|
64 | 64 | { |
65 | 65 | return self::$commandSets->show()->showNumber($variableName, $formatString); |
66 | 66 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
89 | 89 | */ |
90 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
90 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
91 | 91 | { |
92 | 92 | return self::$commandSets->set()->setVar($variableName, $value, $quoteValue); |
93 | 93 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | return self::$commandSets->if()->end(); |
121 | 121 | } |
122 | 122 | |
123 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
123 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
124 | 124 | { |
125 | 125 | return self::$commandSets->if()->if($condition, $type); |
126 | 126 | } |
127 | 127 | |
128 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
128 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
129 | 129 | { |
130 | 130 | return self::$commandSets->if()->ifVar($variable, $operand, $value, $quoteValue); |
131 | 131 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | return self::$commandSets->if()->ifVarString($variable, $operand, $value); |
136 | 136 | } |
137 | 137 | |
138 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
138 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
139 | 139 | { |
140 | 140 | return self::$commandSets->if()->ifVarEquals($variable, $value, $quoteValue); |
141 | 141 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return self::$commandSets->if()->ifVarEqualsString($variable, $value); |
146 | 146 | } |
147 | 147 | |
148 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
148 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
149 | 149 | { |
150 | 150 | return self::$commandSets->if()->ifVarNotEquals($variable, $value, $quoteValue); |
151 | 151 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return self::$commandSets->if()->ifVarNotEqualsString($variable, $value); |
156 | 156 | } |
157 | 157 | |
158 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
158 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
159 | 159 | { |
160 | 160 | return self::$commandSets->elseIf()->elseIf($condition, $type); |
161 | 161 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return self::$commandSets->elseIf()->elseIfNotEmpty($variable); |
171 | 171 | } |
172 | 172 | |
173 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
173 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
174 | 174 | { |
175 | 175 | return self::$commandSets->elseIf()->elseIfVar($variable, $operand, $value, $quoteValue); |
176 | 176 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | return self::$commandSets->elseIf()->elseIfVarString($variable, $operand, $value); |
181 | 181 | } |
182 | 182 | |
183 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
183 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
184 | 184 | { |
185 | 185 | return self::$commandSets->elseIf()->elseIfVarEquals($variable, $value, $quoteValue); |
186 | 186 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return self::$commandSets->elseIf()->elseIfVarEqualsString($variable, $value); |
191 | 191 | } |
192 | 192 | |
193 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
193 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
194 | 194 | { |
195 | 195 | return self::$commandSets->elseIf()->elseIfVarNotEquals($variable, $value, $quoteValue); |
196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return self::$commandSets->elseIf()->elseIfVarNotEqualsString($variable, $value); |
201 | 201 | } |
202 | 202 | |
203 | - public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith |
|
203 | + public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_BeginsWith |
|
204 | 204 | { |
205 | 205 | return self::$commandSets->if()->ifBeginsWith($variable, $search, $caseInsensitive); |
206 | 206 | } |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | return self::$commandSets->if()->ifVarEqualsNumber($variable, $number); |
221 | 221 | } |
222 | 222 | |
223 | - public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith |
|
223 | + public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_EndsWith |
|
224 | 224 | { |
225 | 225 | return self::$commandSets->if()->ifEndsWith($variable, $search, $caseInsensitive); |
226 | 226 | } |
227 | 227 | |
228 | - public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
228 | + public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
229 | 229 | { |
230 | 230 | return self::$commandSets->elseIf()->elseIfBeginsWith($variable, $search, $caseInsensitive); |
231 | 231 | } |
232 | 232 | |
233 | - public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
233 | + public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
234 | 234 | { |
235 | 235 | return self::$commandSets->elseIf()->elseIfEndsWith($variable, $search, $caseInsensitive); |
236 | 236 | } |
237 | 237 | |
238 | - public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
238 | + public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
239 | 239 | { |
240 | 240 | return self::$commandSets->if()->ifContains($variable, array($search), $caseInsensitive); |
241 | 241 | } |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | * @param bool $caseInsensitive |
264 | 264 | * @return Mailcode_Commands_Command_If_Contains |
265 | 265 | */ |
266 | - public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
266 | + public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
267 | 267 | { |
268 | 268 | return self::$commandSets->if()->ifContains($variable, $searchTerms, $caseInsensitive); |
269 | 269 | } |
270 | 270 | |
271 | - public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
271 | + public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
272 | 272 | { |
273 | 273 | return self::$commandSets->elseIf()->elseIfContains($variable, array($search), $caseInsensitive); |
274 | 274 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @param bool $caseInsensitive |
282 | 282 | * @return Mailcode_Commands_Command_ElseIf_Contains |
283 | 283 | */ |
284 | - public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
284 | + public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
285 | 285 | { |
286 | 286 | return self::$commandSets->elseIf()->elseIfContains($variable, $searchTerms, $caseInsensitive); |
287 | 287 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | return self::$commandSets->if()->ifNotEmpty($variable); |
297 | 297 | } |
298 | 298 | |
299 | - public static function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
299 | + public static function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
300 | 300 | { |
301 | 301 | return self::$commandSets->misc()->for($sourceVariable, $loopVariable); |
302 | 302 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | |
337 | 337 | public static function init() : void |
338 | 338 | { |
339 | - if(!isset(self::$commandSets)) |
|
339 | + if (!isset(self::$commandSets)) |
|
340 | 340 | { |
341 | 341 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
342 | 342 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $tokens = $this->params->getInfo()->getStringLiterals(); |
66 | 66 | |
67 | 67 | // no format specified? Use the default one. |
68 | - if(empty($tokens)) |
|
68 | + if (empty($tokens)) |
|
69 | 69 | { |
70 | 70 | return; |
71 | 71 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $result = $this->formatInfo->validateFormat($format); |
80 | 80 | |
81 | - if($result->isValid()) |
|
81 | + if ($result->isValid()) |
|
82 | 82 | { |
83 | 83 | $this->formatString = $format; |
84 | 84 | return; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $tokens = $this->params->getInfo()->getStringLiterals(); |
67 | 67 | |
68 | 68 | // no format specified? Use the default one. |
69 | - if(empty($tokens)) |
|
69 | + if (empty($tokens)) |
|
70 | 70 | { |
71 | 71 | return; |
72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | $result = new Mailcode_Number_Info($format); |
81 | 81 | |
82 | - if($result->isValid()) |
|
82 | + if ($result->isValid()) |
|
83 | 83 | { |
84 | 84 | $this->formatString = $format; |
85 | 85 | return; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $format = trim($format); |
44 | 44 | |
45 | - if(empty($format)) |
|
45 | + if (empty($format)) |
|
46 | 46 | { |
47 | 47 | $format = self::DEFAULT_FORMAT; |
48 | 48 | } |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | { |
109 | 109 | $format = $this->format; |
110 | 110 | |
111 | - foreach($this->validations as $validation) |
|
111 | + foreach ($this->validations as $validation) |
|
112 | 112 | { |
113 | 113 | $method = 'parse_'.$validation; |
114 | 114 | |
115 | - if(method_exists($this, $method)) |
|
115 | + if (method_exists($this, $method)) |
|
116 | 116 | { |
117 | 117 | $format = $this->$method($format); |
118 | 118 | |
119 | - if(!$this->isValid()) |
|
119 | + if (!$this->isValid()) |
|
120 | 120 | { |
121 | 121 | return; |
122 | 122 | } |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | |
139 | 139 | private function parse_padding(string $format) : string |
140 | 140 | { |
141 | - if(strstr($format, ':') === false) { |
|
141 | + if (strstr($format, ':') === false) { |
|
142 | 142 | return $format; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $parts = ConvertHelper::explodeTrim(':', $this->format); |
146 | 146 | |
147 | - if(count($parts) !== 2) |
|
147 | + if (count($parts) !== 2) |
|
148 | 148 | { |
149 | 149 | $this->makeError( |
150 | 150 | t( |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | $padding = $parts[1]; |
161 | 161 | |
162 | - if(!preg_match('/\A[#]+\z/x', $padding)) |
|
162 | + if (!preg_match('/\A[#]+\z/x', $padding)) |
|
163 | 163 | { |
164 | 164 | $this->makeError( |
165 | 165 | t('The padding may only contain hashes (%1$s given).', '<code>'.$padding.'</code>'), |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | private function parse_number(string $format) : string |
178 | 178 | { |
179 | - if($format[0] !== '1') |
|
179 | + if ($format[0] !== '1') |
|
180 | 180 | { |
181 | 181 | $this->makeError( |
182 | 182 | t('The first character of the format must be a %1$s.', '<code>1</code>'), |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $base = str_replace(array('.', ',', ' '), '', $format); |
191 | 191 | $number = intval(substr($base, 0, 4)); |
192 | 192 | |
193 | - if($number === 1000) { |
|
193 | + if ($number === 1000) { |
|
194 | 194 | return $format; |
195 | 195 | } |
196 | 196 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $separator = $format[1]; |
211 | 211 | |
212 | 212 | // No thousands separator |
213 | - if($separator === '0') |
|
213 | + if ($separator === '0') |
|
214 | 214 | { |
215 | 215 | return $format; |
216 | 216 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | // Valid thousands separator |
219 | 219 | $validSeparators = array(' ', ',', '.'); |
220 | 220 | |
221 | - if(in_array($separator, $validSeparators)) |
|
221 | + if (in_array($separator, $validSeparators)) |
|
222 | 222 | { |
223 | 223 | $this->thousandsSeparator = $separator; |
224 | 224 | $format = str_replace('1'.$separator, '1', $format); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | private function parse_separators(string $format) : string |
256 | 256 | { |
257 | - if(!empty($this->thousandsSeparator) && !empty($this->decimalsSeparator) && $this->thousandsSeparator === $this->decimalsSeparator) |
|
257 | + if (!empty($this->thousandsSeparator) && !empty($this->decimalsSeparator) && $this->thousandsSeparator === $this->decimalsSeparator) |
|
258 | 258 | { |
259 | 259 | $this->makeError( |
260 | 260 | t( |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | |
271 | 271 | private function parse_decimals(string $format) : string |
272 | 272 | { |
273 | - if(empty($this->decimalsSeparator)) |
|
273 | + if (empty($this->decimalsSeparator)) |
|
274 | 274 | { |
275 | 275 | return $format; |
276 | 276 | } |
277 | 277 | |
278 | 278 | $parts = ConvertHelper::explodeTrim($this->decimalsSeparator, $format); |
279 | 279 | |
280 | - if(!isset($parts[1])) |
|
280 | + if (!isset($parts[1])) |
|
281 | 281 | { |
282 | 282 | $this->makeError( |
283 | 283 | t('Cannot determine the amount of decimals.').' '. |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | return $format; |
294 | 294 | } |
295 | 295 | |
296 | - if($this->validateDecimals($parts[1])) |
|
296 | + if ($this->validateDecimals($parts[1])) |
|
297 | 297 | { |
298 | 298 | $this->decimals = strlen($parts[1]); |
299 | 299 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | private function validateDecimals(string $decimals) : bool |
305 | 305 | { |
306 | - if(preg_match('/\A[0]+\z/x', $decimals)) { |
|
306 | + if (preg_match('/\A[0]+\z/x', $decimals)) { |
|
307 | 307 | return true; |
308 | 308 | } |
309 | 309 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | $validSeparators = array('.', ','); |
324 | 324 | |
325 | - if(in_array($separator, $validSeparators)) { |
|
325 | + if (in_array($separator, $validSeparators)) { |
|
326 | 326 | return true; |
327 | 327 | } |
328 | 328 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | private function parse_regex(string $format) : string |
346 | 346 | { |
347 | - if(preg_match('/1[ ,.]?000|1[ ,.]?000[.,][0]+/x', $format)) |
|
347 | + if (preg_match('/1[ ,.]?000|1[ ,.]?000[.,][0]+/x', $format)) |
|
348 | 348 | { |
349 | 349 | return $format; |
350 | 350 | } |