@@ -13,15 +13,15 @@ |
||
13 | 13 | return print_r($result, true); |
14 | 14 | } |
15 | 15 | |
16 | - protected function traverseArray(array $array, int $level=0) : array |
|
16 | + protected function traverseArray(array $array, int $level = 0) : array |
|
17 | 17 | { |
18 | 18 | $result = array(); |
19 | 19 | |
20 | - foreach($array as $key => $val) |
|
20 | + foreach ($array as $key => $val) |
|
21 | 21 | { |
22 | - if(is_array($val)) |
|
22 | + if (is_array($val)) |
|
23 | 23 | { |
24 | - $result[$key] = $this->traverseArray($val, ($level+1)); |
|
24 | + $result[$key] = $this->traverseArray($val, ($level + 1)); |
|
25 | 25 | } |
26 | 26 | else |
27 | 27 | { |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | $interval = $d2->diff($d1); |
59 | 59 | |
60 | - if(!$interval instanceof \DateInterval) |
|
60 | + if (!$interval instanceof \DateInterval) |
|
61 | 61 | { |
62 | 62 | throw new ConvertHelper_Exception( |
63 | 63 | 'Cannot create interval', |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // error wrappers. |
84 | 84 | $errors = libxml_get_errors(); |
85 | 85 | |
86 | - foreach($errors as $error) |
|
86 | + foreach ($errors as $error) |
|
87 | 87 | { |
88 | 88 | $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error); |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $xml = $function($subject); |
99 | 99 | |
100 | - if($xml instanceof \SimpleXMLElement) |
|
100 | + if ($xml instanceof \SimpleXMLElement) |
|
101 | 101 | { |
102 | 102 | return $xml; |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getConverter() : XMLHelper_Converter |
109 | 109 | { |
110 | - if($this->element instanceof \SimpleXMLElement) |
|
110 | + if ($this->element instanceof \SimpleXMLElement) |
|
111 | 111 | { |
112 | 112 | return XMLHelper::convertElement($this->element); |
113 | 113 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $data = @json_decode($serialized, true); |
48 | 48 | |
49 | - if(!is_array($data)) |
|
49 | + if (!is_array($data)) |
|
50 | 50 | { |
51 | 51 | throw new XMLHelper_Exception( |
52 | 52 | 'Could not unserialize error data', |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | private static function checkErrorData(array $data) : void |
74 | 74 | { |
75 | - foreach(self::$requiredKeys as $key) |
|
75 | + foreach (self::$requiredKeys as $key) |
|
76 | 76 | { |
77 | - if(!array_key_exists($key, $data)) |
|
77 | + if (!array_key_exists($key, $data)) |
|
78 | 78 | { |
79 | 79 | throw new XMLHelper_Exception( |
80 | 80 | 'Required key missing in error data', |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | - if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
110 | + if (!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
111 | 111 | { |
112 | 112 | return; |
113 | 113 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | // capture all elements except the body tag itself |
209 | 209 | $xml = ''; |
210 | - foreach($nodes as $child) |
|
210 | + foreach ($nodes as $child) |
|
211 | 211 | { |
212 | 212 | $xml .= $this->dom->saveXML($child); |
213 | 213 | } |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(array $libxmlErrors) |
35 | 35 | { |
36 | - foreach($libxmlErrors as $error) |
|
36 | + foreach ($libxmlErrors as $error) |
|
37 | 37 | { |
38 | - if($error instanceof XMLHelper_DOMErrors_Error) |
|
38 | + if ($error instanceof XMLHelper_DOMErrors_Error) |
|
39 | 39 | { |
40 | 40 | $this->errors[] = $error; |
41 | 41 | } |
42 | - else if($error instanceof \LibXMLError) |
|
42 | + else if ($error instanceof \LibXMLError) |
|
43 | 43 | { |
44 | 44 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
45 | 45 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $result = array(); |
119 | 119 | |
120 | - foreach($this->errors as $error) |
|
120 | + foreach ($this->errors as $error) |
|
121 | 121 | { |
122 | - if($error->isLevel($level)) |
|
122 | + if ($error->isLevel($level)) |
|
123 | 123 | { |
124 | 124 | $result[] = $error; |
125 | 125 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | { |
139 | 139 | $result = array(); |
140 | 140 | |
141 | - foreach($this->errors as $error) |
|
141 | + foreach ($this->errors as $error) |
|
142 | 142 | { |
143 | - if($error->isCode($code)) |
|
143 | + if ($error->isCode($code)) |
|
144 | 144 | { |
145 | 145 | $result[] = $error; |
146 | 146 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function hasErrorsByLevel(int $level) : bool |
159 | 159 | { |
160 | - foreach($this->errors as $error) |
|
160 | + foreach ($this->errors as $error) |
|
161 | 161 | { |
162 | - if($error->isLevel($level)) |
|
162 | + if ($error->isLevel($level)) |
|
163 | 163 | { |
164 | 164 | return true; |
165 | 165 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function hasErrorsByCode(int $code) : bool |
178 | 178 | { |
179 | - foreach($this->errors as $error) |
|
179 | + foreach ($this->errors as $error) |
|
180 | 180 | { |
181 | - if($error->isCode($code)) |
|
181 | + if ($error->isCode($code)) |
|
182 | 182 | { |
183 | 183 | return true; |
184 | 184 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $result = array(); |
193 | 193 | |
194 | - foreach($this->errors as $error) |
|
194 | + foreach ($this->errors as $error) |
|
195 | 195 | { |
196 | 196 | $result[] = $error->toArray(); |
197 | 197 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $data = array(); |
212 | 212 | |
213 | - foreach($this->errors as $error) |
|
213 | + foreach ($this->errors as $error) |
|
214 | 214 | { |
215 | 215 | $data[] = $error->serialize(); |
216 | 216 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $parts = explode(self::SERIALIZE_SEPARATOR, $serialized); |
232 | 232 | $list = array(); |
233 | 233 | |
234 | - foreach($parts as $part) |
|
234 | + foreach ($parts as $part) |
|
235 | 235 | { |
236 | 236 | $list[] = XMLHelper_DOMErrors_Error::fromSerialized($part); |
237 | 237 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $lines = explode("\n", $list); |
23 | 23 | $reverseArray = array(); |
24 | 24 | |
25 | - foreach($lines as $line) |
|
25 | + foreach ($lines as $line) |
|
26 | 26 | { |
27 | 27 | $parts = explode('=', $line); |
28 | 28 | $name = trim(str_replace('XML_ERR_', '', $parts[0])); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $message Should not contain a date, just the system specific info. |
143 | 143 | * @return OperationResult |
144 | 144 | */ |
145 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
145 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
146 | 146 | { |
147 | 147 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $message Should be as detailed as possible. |
154 | 154 | * @return OperationResult |
155 | 155 | */ |
156 | - public function makeError(string $message, int $code=0) : OperationResult |
|
156 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
157 | 157 | { |
158 | 158 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
159 | 159 | } |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | return $this->code; |
234 | 234 | } |
235 | 235 | |
236 | - public function getMessage(string $type='') : string |
|
236 | + public function getMessage(string $type = '') : string |
|
237 | 237 | { |
238 | - if(!empty($type)) |
|
238 | + if (!empty($type)) |
|
239 | 239 | { |
240 | - if($this->type === $type) |
|
240 | + if ($this->type === $type) |
|
241 | 241 | { |
242 | 242 | return $this->message; |
243 | 243 | } |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected $results = array(); |
33 | 33 | |
34 | - public function makeError(string $message, int $code=0) : OperationResult |
|
34 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
35 | 35 | { |
36 | 36 | return $this->add('makeError', $message, $code); |
37 | 37 | } |
38 | 38 | |
39 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
39 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
40 | 40 | { |
41 | 41 | return $this->add('makeSuccess', $message, $code); |
42 | 42 | } |
43 | 43 | |
44 | - public function makeWarning(string $message, int $code=0) : OperationResult |
|
44 | + public function makeWarning(string $message, int $code = 0) : OperationResult |
|
45 | 45 | { |
46 | 46 | return $this->add('makeWarning', $message, $code); |
47 | 47 | } |
48 | 48 | |
49 | - public function makeNotice(string $message, int $code=0) : OperationResult |
|
49 | + public function makeNotice(string $message, int $code = 0) : OperationResult |
|
50 | 50 | { |
51 | 51 | return $this->add('makeNotice', $message, $code); |
52 | 52 | } |
53 | 53 | |
54 | - protected function add(string $method, string $message, int $code=0) : OperationResult |
|
54 | + protected function add(string $method, string $message, int $code = 0) : OperationResult |
|
55 | 55 | { |
56 | 56 | $result = new OperationResult($this->subject); |
57 | 57 | $result->$method($message, $code); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function addResult(OperationResult $result) : OperationResult_Collection |
65 | 65 | { |
66 | - if($result instanceof OperationResult_Collection) |
|
66 | + if ($result instanceof OperationResult_Collection) |
|
67 | 67 | { |
68 | 68 | return $this->importCollection($result); |
69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | $results = $collection->getResults(); |
77 | 77 | |
78 | - foreach($results as $result) |
|
78 | + foreach ($results as $result) |
|
79 | 79 | { |
80 | 80 | $this->addResult($result); |
81 | 81 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | public function isValid() : bool |
113 | 113 | { |
114 | - foreach($this->results as $result) |
|
114 | + foreach ($this->results as $result) |
|
115 | 115 | { |
116 | - if(!$result->isValid()) |
|
116 | + if (!$result->isValid()) |
|
117 | 117 | { |
118 | 118 | return false; |
119 | 119 | } |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | |
125 | 125 | public function hasCode() : bool |
126 | 126 | { |
127 | - foreach($this->results as $result) |
|
127 | + foreach ($this->results as $result) |
|
128 | 128 | { |
129 | - if($result->hasCode()) |
|
129 | + if ($result->hasCode()) |
|
130 | 130 | { |
131 | 131 | return true; |
132 | 132 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | public function getCode() : int |
139 | 139 | { |
140 | - foreach($this->results as $result) |
|
140 | + foreach ($this->results as $result) |
|
141 | 141 | { |
142 | - if($result->hasCode()) |
|
142 | + if ($result->hasCode()) |
|
143 | 143 | { |
144 | 144 | return $result->getCode(); |
145 | 145 | } |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | return 0; |
149 | 149 | } |
150 | 150 | |
151 | - public function getMessage(string $type='') : string |
|
151 | + public function getMessage(string $type = '') : string |
|
152 | 152 | { |
153 | - foreach($this->results as $result) |
|
153 | + foreach ($this->results as $result) |
|
154 | 154 | { |
155 | 155 | $msg = $result->getMessage($type); |
156 | 156 | |
157 | - if(!empty($msg)) |
|
157 | + if (!empty($msg)) |
|
158 | 158 | { |
159 | 159 | return $msg; |
160 | 160 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | |
166 | 166 | public function containsCode(int $code) : bool |
167 | 167 | { |
168 | - foreach($this->results as $result) |
|
168 | + foreach ($this->results as $result) |
|
169 | 169 | { |
170 | - if($result->getCode() === $code) |
|
170 | + if ($result->getCode() === $code) |
|
171 | 171 | { |
172 | 172 | return true; |
173 | 173 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | { |
201 | 201 | $amount = 0; |
202 | 202 | |
203 | - foreach($this->results as $result) |
|
203 | + foreach ($this->results as $result) |
|
204 | 204 | { |
205 | - if($result->isType($type)) |
|
205 | + if ($result->isType($type)) |
|
206 | 206 | { |
207 | 207 | $amount++; |
208 | 208 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | { |
241 | 241 | $results = array(); |
242 | 242 | |
243 | - foreach($this->results as $result) |
|
243 | + foreach ($this->results as $result) |
|
244 | 244 | { |
245 | - if($result->isType($type)) |
|
245 | + if ($result->isType($type)) |
|
246 | 246 | { |
247 | 247 | $results[] = $result; |
248 | 248 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | |
254 | 254 | public function isType(string $type) : bool |
255 | 255 | { |
256 | - foreach($this->results as $result) |
|
256 | + foreach ($this->results as $result) |
|
257 | 257 | { |
258 | - if($result->isType($type)) |
|
258 | + if ($result->isType($type)) |
|
259 | 259 | { |
260 | 260 | return true; |
261 | 261 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $lines[] = 'Collection #'.$this->getID(); |
272 | 272 | $lines[] = 'Subject: '.get_class($this->subject); |
273 | 273 | |
274 | - foreach($this->results as $result) |
|
274 | + foreach ($this->results as $result) |
|
275 | 275 | { |
276 | 276 | $lines[] = ' - '.$result->getType().' #'.$result->getCode().' "'.$result->getMessage($result->getType()).'"'; |
277 | 277 | } |