@@ -33,7 +33,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | // All other special characters have to be escaped |
71 | 71 | // with two backslashes. |
72 | - foreach($this->regexSpecialChars as $char) |
|
72 | + foreach ($this->regexSpecialChars as $char) |
|
73 | 73 | { |
74 | 74 | $string = str_replace($char, '\\'.$char, $string); |
75 | 75 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | protected function addURLEncoding(Mailcode_Commands_Command $command, string $statement) : string |
85 | 85 | { |
86 | - if($command->isURLEncoded()) |
|
86 | + if ($command->isURLEncoded()) |
|
87 | 87 | { |
88 | 88 | return sprintf( |
89 | 89 | '${esc.url($%s)}', |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - if($command->isURLDecoded()) |
|
94 | + if ($command->isURLDecoded()) |
|
95 | 95 | { |
96 | 96 | return sprintf( |
97 | 97 | '${esc.unurl($%s)}', |
@@ -56,7 +56,7 @@ 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 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $chars = ConvertHelper::string2array($formatString); |
77 | 77 | $result = array(); |
78 | 78 | |
79 | - foreach($chars as $char) |
|
79 | + foreach ($chars as $char) |
|
80 | 80 | { |
81 | - if(!isset($this->charTable[$char])) |
|
81 | + if (!isset($this->charTable[$char])) |
|
82 | 82 | { |
83 | 83 | throw new Mailcode_Translator_Exception( |
84 | 84 | 'Unknown date format string character', |
@@ -2,7 +2,7 @@ |
||
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 |
@@ -30,7 +30,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"> |
@@ -46,7 +46,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -79,7 +79,7 @@ |
||
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); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $val = $this->validator->createStringLiteral(); |
73 | 73 | |
74 | - if($val->isValid()) |
|
74 | + if ($val->isValid()) |
|
75 | 75 | { |
76 | 76 | $this->sourceFormat = strtoupper($val->getToken()->getText()); |
77 | 77 | return; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | $countries = self::getSupportedCountries(); |
95 | 95 | |
96 | - if(isset($countries[$this->sourceFormat])) { |
|
96 | + if (isset($countries[$this->sourceFormat])) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function getSupportedCountries() : array |
114 | 114 | { |
115 | - if(self::$countriesLoaded) { |
|
115 | + if (self::$countriesLoaded) { |
|
116 | 116 | return self::$supportedCountries; |
117 | 117 | } |
118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $data = FileHelper::parseJSONFile(__DIR__.'/ShowPhone/numbers.json'); |
122 | 122 | |
123 | - foreach($data as $code => $def) |
|
123 | + foreach ($data as $code => $def) |
|
124 | 124 | { |
125 | 125 | $code = strval($code); |
126 | 126 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function normalize() : string |
39 | 39 | { |
40 | - if(!$this->command->isValid()) |
|
40 | + if (!$this->command->isValid()) |
|
41 | 41 | { |
42 | 42 | return ''; |
43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | private function addType() : void |
59 | 59 | { |
60 | - if(!$this->command->supportsType() || !$this->command->hasType()) |
|
60 | + if (!$this->command->supportsType() || !$this->command->hasType()) |
|
61 | 61 | { |
62 | 62 | return; |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | private function addParams(Mailcode_Commands_Command $command) : void |
69 | 69 | { |
70 | - if($command->hasFreeformParameters()) |
|
70 | + if ($command->hasFreeformParameters()) |
|
71 | 71 | { |
72 | 72 | $params = $command->getParams()->getStatementString(); |
73 | 73 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $params = $command->getParams()->getNormalized(); |
77 | 77 | } |
78 | 78 | |
79 | - if(empty($params)) |
|
79 | + if (empty($params)) |
|
80 | 80 | { |
81 | 81 | return; |
82 | 82 | } |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | |
88 | 88 | private function addLogicKeywords() : void |
89 | 89 | { |
90 | - if(!$this->command->supportsLogicKeywords()) |
|
90 | + if (!$this->command->supportsLogicKeywords()) |
|
91 | 91 | { |
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $keywords = $this->command->getLogicKeywords()->getKeywords(); |
96 | 96 | |
97 | - foreach($keywords as $keyword) |
|
97 | + foreach ($keywords as $keyword) |
|
98 | 98 | { |
99 | 99 | $this->parts[] = ' '; |
100 | 100 | $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable" |