@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param \Exception|NULL $previous |
33 | 33 | * @param Mailcode_Commands_Command|NULL $command |
34 | 34 | */ |
35 | - public function __construct(string $message, $details=null, $code=null, $previous=null, Mailcode_Commands_Command $command=null) |
|
35 | + public function __construct(string $message, $details = null, $code = null, $previous = null, Mailcode_Commands_Command $command = null) |
|
36 | 36 | { |
37 | 37 | parent::__construct($message, $details, $code, $previous); |
38 | 38 |
@@ -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 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function fixName(string $fullName) : string |
108 | 108 | { |
109 | - if(substr($fullName, 0, 1) === '$') |
|
109 | + if (substr($fullName, 0, 1) === '$') |
|
110 | 110 | { |
111 | 111 | return $fullName; |
112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $entries = array(); |
126 | 126 | |
127 | - foreach($this->variables as $variable) |
|
127 | + foreach ($this->variables as $variable) |
|
128 | 128 | { |
129 | 129 | $entries[$variable->getHash()] = $variable; |
130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | $entries = array(); |
143 | 143 | |
144 | - foreach($this->variables as $variable) |
|
144 | + foreach ($this->variables as $variable) |
|
145 | 145 | { |
146 | 146 | $entries[$variable->getFullName()] = $variable; |
147 | 147 | } |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | { |
167 | 167 | $result = array(); |
168 | 168 | |
169 | - foreach($this->variables as $variable) |
|
169 | + foreach ($this->variables as $variable) |
|
170 | 170 | { |
171 | 171 | $name = $variable->getFullName(); |
172 | 172 | |
173 | - if(!in_array($name, $result)) |
|
173 | + if (!in_array($name, $result)) |
|
174 | 174 | { |
175 | 175 | $result[] = $name; |
176 | 176 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $variables = $collection->getGroupedByHash(); |
211 | 211 | |
212 | - foreach($variables as $variable) |
|
212 | + foreach ($variables as $variable) |
|
213 | 213 | { |
214 | 214 | $this->add($variable); |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | $variables = $this->getAll(); |
223 | 223 | |
224 | - if(!empty($variables)) |
|
224 | + if (!empty($variables)) |
|
225 | 225 | { |
226 | 226 | return array_shift($variables); |
227 | 227 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function getFullName() : string |
78 | 78 | { |
79 | - if(empty($this->path)) |
|
79 | + if (empty($this->path)) |
|
80 | 80 | { |
81 | 81 | return '$'.$this->name; |
82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function getHash() : string |
103 | 103 | { |
104 | - if(empty($this->hash)) |
|
104 | + if (empty($this->hash)) |
|
105 | 105 | { |
106 | 106 | $this->hash = md5($this->matchedText); |
107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function getValidationResult() : OperationResult |
118 | 118 | { |
119 | - if(isset($this->validationResult)) |
|
119 | + if (isset($this->validationResult)) |
|
120 | 120 | { |
121 | 121 | return $this->validationResult; |
122 | 122 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | |
131 | 131 | protected function validate() : void |
132 | 132 | { |
133 | - foreach($this->validations as $validation) |
|
133 | + foreach ($this->validations as $validation) |
|
134 | 134 | { |
135 | 135 | $method = 'validate_'.$validation; |
136 | 136 | |
137 | - if(!method_exists($this, $method)) |
|
137 | + if (!method_exists($this, $method)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Unknown validation method', |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $this->$method(); |
151 | 151 | |
152 | - if(!$this->validationResult->isValid()) |
|
152 | + if (!$this->validationResult->isValid()) |
|
153 | 153 | { |
154 | 154 | return; |
155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | protected function validateNumber(string $value, int $errorCode) : void |
180 | 180 | { |
181 | - if(!is_numeric(substr($value, 0, 1))) |
|
181 | + if (!is_numeric(substr($value, 0, 1))) |
|
182 | 182 | { |
183 | 183 | return; |
184 | 184 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | protected function validateUnderscore(string $value, int $errorCode) : void |
197 | 197 | { |
198 | 198 | // allow empty paths |
199 | - if(empty($value)) |
|
199 | + if (empty($value)) |
|
200 | 200 | { |
201 | 201 | return; |
202 | 202 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $length = strlen($value); |
205 | 205 | |
206 | 206 | // trimming underscores does not change the length: no underscores at start or end of string. |
207 | - if(strlen(trim($value, '_')) == $length) |
|
207 | + if (strlen(trim($value, '_')) == $length) |
|
208 | 208 | { |
209 | 209 | return; |
210 | 210 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | $matches = array(); |
41 | 41 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
42 | 42 | |
43 | - if(!isset($matches[0]) || empty($matches[0])) |
|
43 | + if (!isset($matches[0]) || empty($matches[0])) |
|
44 | 44 | { |
45 | 45 | return $this->collection; |
46 | 46 | } |
47 | 47 | |
48 | - foreach($matches[0] as $idx => $matchedText) |
|
48 | + foreach ($matches[0] as $idx => $matchedText) |
|
49 | 49 | { |
50 | - if(!empty($matches[3][$idx])) |
|
50 | + if (!empty($matches[3][$idx])) |
|
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function addSingle(string $name, string $matchedText) : void |
64 | 64 | { |
65 | 65 | // ignore US style numbers like $451 |
66 | - if(is_numeric($name)) |
|
66 | + if (is_numeric($name)) |
|
67 | 67 | { |
68 | 68 | return; |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function addPathed(string $path, string $name, string $matchedText) : void |
75 | 75 | { |
76 | 76 | // ignore US style numbers like $45.12 |
77 | - if(is_numeric($path.'.'.$name)) |
|
77 | + if (is_numeric($path.'.'.$name)) |
|
78 | 78 | { |
79 | 79 | return; |
80 | 80 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getParser() : Mailcode_Parser |
75 | 75 | { |
76 | - if(!isset($this->parser)) |
|
76 | + if (!isset($this->parser)) |
|
77 | 77 | { |
78 | 78 | $this->parser = new Mailcode_Parser($this); |
79 | 79 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function getCommands() : Mailcode_Commands |
91 | 91 | { |
92 | - if(!isset($this->commands)) |
|
92 | + if (!isset($this->commands)) |
|
93 | 93 | { |
94 | 94 | $this->commands = new Mailcode_Commands(); |
95 | 95 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | public function createVariables() : Mailcode_Variables |
117 | 117 | { |
118 | - if(!isset($this->variables)) |
|
118 | + if (!isset($this->variables)) |
|
119 | 119 | { |
120 | 120 | $this->variables = new Mailcode_Variables(); |
121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function createTranslator() : Mailcode_Translator |
133 | 133 | { |
134 | - if(!isset($this->translator)) |
|
134 | + if (!isset($this->translator)) |
|
135 | 135 | { |
136 | 136 | $this->translator = new Mailcode_Translator(); |
137 | 137 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $total = count($matches[0]); |
75 | 75 | |
76 | - for($i=0; $i < $total; $i++) |
|
76 | + for ($i = 0; $i < $total; $i++) |
|
77 | 77 | { |
78 | 78 | $match = $this->parseMatch($matches, $i); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | protected function prepareString(string $subject) : string |
87 | 87 | { |
88 | - if(!ConvertHelper::isStringHTML($subject)) |
|
88 | + if (!ConvertHelper::isStringHTML($subject)) |
|
89 | 89 | { |
90 | 90 | return $subject; |
91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $name = $match->getName(); |
108 | 108 | |
109 | - if(!$this->commands->nameExists($name)) |
|
109 | + if (!$this->commands->nameExists($name)) |
|
110 | 110 | { |
111 | 111 | $collection->addErrorMessage( |
112 | 112 | $match->getMatchedString(), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $match->getMatchedString() |
124 | 124 | ); |
125 | 125 | |
126 | - if($cmd->isValid()) |
|
126 | + if ($cmd->isValid()) |
|
127 | 127 | { |
128 | 128 | $collection->addCommand($cmd); |
129 | 129 | return; |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | // 5 = parameter type command, type |
154 | 154 | // 6 = parameter type command, params |
155 | 155 | |
156 | - if(!empty($matches[1][$index])) |
|
156 | + if (!empty($matches[1][$index])) |
|
157 | 157 | { |
158 | 158 | $name = $matches[1][$index]; |
159 | 159 | } |
160 | - else if(!empty($matches[2][$index])) |
|
160 | + else if (!empty($matches[2][$index])) |
|
161 | 161 | { |
162 | 162 | $name = $matches[2][$index]; |
163 | 163 | $params = $matches[3][$index]; |
164 | 164 | } |
165 | - else if(!empty($matches[4][$index])) |
|
165 | + else if (!empty($matches[4][$index])) |
|
166 | 166 | { |
167 | 167 | $name = $matches[4][$index]; |
168 | 168 | $type = $matches[5][$index]; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $this->paramsString = trim($this->paramsString); |
26 | 26 | |
27 | 27 | // automatically quote the parameters, since comments don't require any. |
28 | - if(substr($this->paramsString, 0, 1) != '"') |
|
28 | + if (substr($this->paramsString, 0, 1) != '"') |
|
29 | 29 | { |
30 | 30 | $this->paramsString = '"'.$this->paramsString.'"'; |
31 | 31 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param bool $highlighted |
33 | 33 | * @return Mailcode_Renderer |
34 | 34 | */ |
35 | - public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
|
35 | + public function setOutputHighlighted(bool $highlighted = true) : Mailcode_Renderer |
|
36 | 36 | { |
37 | 37 | $this->highlighted = $highlighted; |
38 | 38 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $this->command2string(Mailcode_Factory::showSnippet($snippetName)); |
56 | 56 | } |
57 | 57 | |
58 | - public function setVar(string $variableName, string $value, bool $quoteValue=false) : string |
|
58 | + public function setVar(string $variableName, string $value, bool $quoteValue = false) : string |
|
59 | 59 | { |
60 | 60 | return $this->command2string(Mailcode_Factory::setVar($variableName, $value, $quoteValue)); |
61 | 61 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | return $this->command2string(Mailcode_Factory::setVarString($variableName, $value)); |
66 | 66 | } |
67 | 67 | |
68 | - public function if(string $condition, string $type='') : string |
|
68 | + public function if (string $condition, string $type = '') : string |
|
69 | 69 | { |
70 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
70 | + return $this->command2string(Mailcode_Factory::if ($condition, $type)); |
|
71 | 71 | } |
72 | 72 | |
73 | - public function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
|
73 | + public function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : string |
|
74 | 74 | { |
75 | 75 | return $this->command2string(Mailcode_Factory::ifVar($variable, $operand, $value, $quoteValue)); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return $this->command2string(Mailcode_Factory::ifVarString($variable, $operand, $value)); |
81 | 81 | } |
82 | 82 | |
83 | - public function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
83 | + public function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
84 | 84 | { |
85 | 85 | return $this->command2string(Mailcode_Factory::ifVarEquals($variable, $value, $quoteValue)); |
86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return $this->command2string(Mailcode_Factory::ifVarEqualsString($variable, $value)); |
91 | 91 | } |
92 | 92 | |
93 | - public function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
93 | + public function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
94 | 94 | { |
95 | 95 | return $this->command2string(Mailcode_Factory::ifVarNotEquals($variable, $value, $quoteValue)); |
96 | 96 | } |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | return $this->command2string(Mailcode_Factory::ifVarNotEqualsString($variable, $value)); |
101 | 101 | } |
102 | 102 | |
103 | - public function elseIf(string $condition, string $type='') : string |
|
103 | + public function elseIf (string $condition, string $type = '') : string |
|
104 | 104 | { |
105 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
105 | + return $this->command2string(Mailcode_Factory::elseIf ($condition, $type)); |
|
106 | 106 | } |
107 | 107 | |
108 | - public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
|
108 | + public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : string |
|
109 | 109 | { |
110 | 110 | return $this->command2string(Mailcode_Factory::elseIfVar($variable, $operand, $value, $quoteValue)); |
111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return $this->command2string(Mailcode_Factory::elseIfVarString($variable, $operand, $value)); |
116 | 116 | } |
117 | 117 | |
118 | - public function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
118 | + public function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
119 | 119 | { |
120 | 120 | return $this->command2string(Mailcode_Factory::elseIfVarEquals($variable, $value, $quoteValue)); |
121 | 121 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | return $this->command2string(Mailcode_Factory::elseIfVarEqualsString($variable, $value)); |
126 | 126 | } |
127 | 127 | |
128 | - public function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
128 | + public function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
129 | 129 | { |
130 | 130 | return $this->command2string(Mailcode_Factory::elseIfVarNotEquals($variable, $value, $quoteValue)); |
131 | 131 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | protected function command2string(Mailcode_Commands_Command $command) : string |
154 | 154 | { |
155 | - if($this->highlighted) |
|
155 | + if ($this->highlighted) |
|
156 | 156 | { |
157 | 157 | return $command->getHighlighted(); |
158 | 158 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | { |
52 | 52 | $this->parts[] = $this->renderTag(array('command-name'), $this->command->getName()); |
53 | 53 | |
54 | - if($this->command->hasType()) |
|
54 | + if ($this->command->hasType()) |
|
55 | 55 | { |
56 | 56 | $this->parts[] = ' '.$this->renderTag(array('command-type'), $this->command->getType()); |
57 | 57 | } |
58 | 58 | |
59 | - if($this->command->requiresParameters()) |
|
59 | + if ($this->command->requiresParameters()) |
|
60 | 60 | { |
61 | 61 | $this->parts[] = $this->renderTag(array('hyphen'), ':'); |
62 | 62 | $this->parts[] = '<wbr>'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function appendParams() : void |
67 | 67 | { |
68 | - if($this->command->hasParameters()) |
|
68 | + if ($this->command->hasParameters()) |
|
69 | 69 | { |
70 | 70 | $this->parts[] = ' '.$this->renderTag(array('params'), $this->command->getParamsString()); |
71 | 71 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $parts = array(); |
82 | 82 | |
83 | - foreach($classes as $class) |
|
83 | + foreach ($classes as $class) |
|
84 | 84 | { |
85 | 85 | $parts[] = 'mailcode-'.$class; |
86 | 86 | } |