@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class OperationResult_Collection extends OperationResult |
28 | 28 | { |
29 | - /** |
|
30 | - * @var OperationResult[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var OperationResult[] |
|
31 | + */ |
|
32 | 32 | protected $results = array(); |
33 | 33 | |
34 | 34 | /** |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | return $this; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * @return OperationResult[] |
|
128 | - */ |
|
126 | + /** |
|
127 | + * @return OperationResult[] |
|
128 | + */ |
|
129 | 129 | public function getResults() : array |
130 | 130 | { |
131 | 131 | return $this->results; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param int $code |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - public function makeError(string $message, int $code=0) : OperationResult |
|
39 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
40 | 40 | { |
41 | 41 | return $this->add('makeError', $message, $code); |
42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int $code |
47 | 47 | * @return $this |
48 | 48 | */ |
49 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
49 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
50 | 50 | { |
51 | 51 | return $this->add('makeSuccess', $message, $code); |
52 | 52 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param int $code |
57 | 57 | * @return $this |
58 | 58 | */ |
59 | - public function makeWarning(string $message, int $code=0) : OperationResult |
|
59 | + public function makeWarning(string $message, int $code = 0) : OperationResult |
|
60 | 60 | { |
61 | 61 | return $this->add('makeWarning', $message, $code); |
62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param int $code |
67 | 67 | * @return $this |
68 | 68 | */ |
69 | - public function makeNotice(string $message, int $code=0) : OperationResult |
|
69 | + public function makeNotice(string $message, int $code = 0) : OperationResult |
|
70 | 70 | { |
71 | 71 | return $this->add('makeNotice', $message, $code); |
72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param int $code |
78 | 78 | * @return $this |
79 | 79 | */ |
80 | - protected function add(string $method, string $message, int $code=0) : OperationResult |
|
80 | + protected function add(string $method, string $message, int $code = 0) : OperationResult |
|
81 | 81 | { |
82 | 82 | $result = new OperationResult($this->subject); |
83 | 83 | $result->$method($message, $code); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function addResult(OperationResult $result) : OperationResult_Collection |
97 | 97 | { |
98 | - if($result instanceof OperationResult_Collection) |
|
98 | + if ($result instanceof OperationResult_Collection) |
|
99 | 99 | { |
100 | 100 | return $this->importCollection($result); |
101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $results = $collection->getResults(); |
117 | 117 | |
118 | - foreach($results as $result) |
|
118 | + foreach ($results as $result) |
|
119 | 119 | { |
120 | 120 | $this->addResult($result); |
121 | 121 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | public function isValid() : bool |
135 | 135 | { |
136 | - foreach($this->results as $result) |
|
136 | + foreach ($this->results as $result) |
|
137 | 137 | { |
138 | - if(!$result->isValid()) |
|
138 | + if (!$result->isValid()) |
|
139 | 139 | { |
140 | 140 | return false; |
141 | 141 | } |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | |
147 | 147 | public function hasCode() : bool |
148 | 148 | { |
149 | - foreach($this->results as $result) |
|
149 | + foreach ($this->results as $result) |
|
150 | 150 | { |
151 | - if($result->hasCode()) |
|
151 | + if ($result->hasCode()) |
|
152 | 152 | { |
153 | 153 | return true; |
154 | 154 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | |
160 | 160 | public function getCode() : int |
161 | 161 | { |
162 | - foreach($this->results as $result) |
|
162 | + foreach ($this->results as $result) |
|
163 | 163 | { |
164 | - if($result->hasCode()) |
|
164 | + if ($result->hasCode()) |
|
165 | 165 | { |
166 | 166 | return $result->getCode(); |
167 | 167 | } |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | return 0; |
171 | 171 | } |
172 | 172 | |
173 | - public function getMessage(string $type='') : string |
|
173 | + public function getMessage(string $type = '') : string |
|
174 | 174 | { |
175 | - foreach($this->results as $result) |
|
175 | + foreach ($this->results as $result) |
|
176 | 176 | { |
177 | 177 | $msg = $result->getMessage($type); |
178 | 178 | |
179 | - if(!empty($msg)) |
|
179 | + if (!empty($msg)) |
|
180 | 180 | { |
181 | 181 | return $msg; |
182 | 182 | } |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | |
188 | 188 | public function containsCode(int $code) : bool |
189 | 189 | { |
190 | - foreach($this->results as $result) |
|
190 | + foreach ($this->results as $result) |
|
191 | 191 | { |
192 | - if($result->getCode() === $code) |
|
192 | + if ($result->getCode() === $code) |
|
193 | 193 | { |
194 | 194 | return true; |
195 | 195 | } |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | { |
223 | 223 | $amount = 0; |
224 | 224 | |
225 | - foreach($this->results as $result) |
|
225 | + foreach ($this->results as $result) |
|
226 | 226 | { |
227 | - if($result->isType($type)) |
|
227 | + if ($result->isType($type)) |
|
228 | 228 | { |
229 | 229 | $amount++; |
230 | 230 | } |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | { |
263 | 263 | $results = array(); |
264 | 264 | |
265 | - foreach($this->results as $result) |
|
265 | + foreach ($this->results as $result) |
|
266 | 266 | { |
267 | - if($result->isType($type)) |
|
267 | + if ($result->isType($type)) |
|
268 | 268 | { |
269 | 269 | $results[] = $result; |
270 | 270 | } |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | |
276 | 276 | public function isType(string $type) : bool |
277 | 277 | { |
278 | - foreach($this->results as $result) |
|
278 | + foreach ($this->results as $result) |
|
279 | 279 | { |
280 | - if($result->isType($type)) |
|
280 | + if ($result->isType($type)) |
|
281 | 281 | { |
282 | 282 | return true; |
283 | 283 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $lines[] = 'Collection #'.$this->getID(); |
294 | 294 | $lines[] = 'Subject: '.get_class($this->subject); |
295 | 295 | |
296 | - foreach($this->results as $result) |
|
296 | + foreach ($this->results as $result) |
|
297 | 297 | { |
298 | 298 | $lines[] = ' - '.$result->getType().' #'.$result->getCode().' "'.$result->getMessage($result->getType()).'"'; |
299 | 299 | } |
@@ -34,46 +34,46 @@ discard block |
||
34 | 34 | const TYPE_ERROR = 'error'; |
35 | 35 | const TYPE_SUCCESS = 'success'; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $message = ''; |
41 | 41 | |
42 | - /** |
|
43 | - * @var bool |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var bool |
|
44 | + */ |
|
45 | 45 | protected $valid = true; |
46 | 46 | |
47 | - /** |
|
48 | - * @var object |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var object |
|
49 | + */ |
|
50 | 50 | protected $subject; |
51 | 51 | |
52 | - /** |
|
53 | - * @var integer |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var integer |
|
54 | + */ |
|
55 | 55 | protected $code = 0; |
56 | 56 | |
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | 60 | protected $type = ''; |
61 | 61 | |
62 | - /** |
|
63 | - * @var integer |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var integer |
|
64 | + */ |
|
65 | 65 | private static $counter = 0; |
66 | 66 | |
67 | - /** |
|
68 | - * @var int |
|
69 | - */ |
|
67 | + /** |
|
68 | + * @var int |
|
69 | + */ |
|
70 | 70 | private $id; |
71 | 71 | |
72 | - /** |
|
73 | - * The subject being validated. |
|
74 | - * |
|
75 | - * @param object $subject |
|
76 | - */ |
|
72 | + /** |
|
73 | + * The subject being validated. |
|
74 | + * |
|
75 | + * @param object $subject |
|
76 | + */ |
|
77 | 77 | public function __construct(object $subject) |
78 | 78 | { |
79 | 79 | $this->subject = $subject; |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | $this->id = self::$counter; |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * Retrieves the ID of the result, which is unique within a request. |
|
88 | - * |
|
89 | - * @return int |
|
90 | - */ |
|
86 | + /** |
|
87 | + * Retrieves the ID of the result, which is unique within a request. |
|
88 | + * |
|
89 | + * @return int |
|
90 | + */ |
|
91 | 91 | public function getID() : int |
92 | 92 | { |
93 | 93 | return $this->id; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether the validation was successful. |
|
98 | - * |
|
99 | - * @return bool |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Whether the validation was successful. |
|
98 | + * |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | 101 | public function isValid() : bool |
102 | 102 | { |
103 | 103 | return $this->valid; |
@@ -128,33 +128,33 @@ discard block |
||
128 | 128 | return $this->type === $type; |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Retrieves the subject that was validated. |
|
133 | - * |
|
134 | - * @return object |
|
135 | - */ |
|
131 | + /** |
|
132 | + * Retrieves the subject that was validated. |
|
133 | + * |
|
134 | + * @return object |
|
135 | + */ |
|
136 | 136 | public function getSubject() : object |
137 | 137 | { |
138 | 138 | return $this->subject; |
139 | 139 | } |
140 | 140 | |
141 | - /** |
|
142 | - * Makes the result a success, with the specified message. |
|
143 | - * |
|
144 | - * @param string $message Should not contain a date, just the system specific info. |
|
145 | - * @return $this |
|
146 | - */ |
|
141 | + /** |
|
142 | + * Makes the result a success, with the specified message. |
|
143 | + * |
|
144 | + * @param string $message Should not contain a date, just the system specific info. |
|
145 | + * @return $this |
|
146 | + */ |
|
147 | 147 | public function makeSuccess(string $message, int $code=0) : OperationResult |
148 | 148 | { |
149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Sets the result as an error. |
|
154 | - * |
|
155 | - * @param string $message Should be as detailed as possible. |
|
156 | - * @return $this |
|
157 | - */ |
|
152 | + /** |
|
153 | + * Sets the result as an error. |
|
154 | + * |
|
155 | + * @param string $message Should be as detailed as possible. |
|
156 | + * @return $this |
|
157 | + */ |
|
158 | 158 | public function makeError(string $message, int $code=0) : OperationResult |
159 | 159 | { |
160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | return $this->type; |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Retrieves the error message, if an error occurred. |
|
207 | - * |
|
208 | - * @return string The error message, or an empty string if no error occurred. |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Retrieves the error message, if an error occurred. |
|
207 | + * |
|
208 | + * @return string The error message, or an empty string if no error occurred. |
|
209 | + */ |
|
210 | 210 | public function getErrorMessage() : string |
211 | 211 | { |
212 | 212 | return $this->getMessage(self::TYPE_ERROR); |
213 | 213 | } |
214 | 214 | |
215 | - /** |
|
216 | - * Retrieves the success message, if one has been provided. |
|
217 | - * |
|
218 | - * @return string |
|
219 | - */ |
|
215 | + /** |
|
216 | + * Retrieves the success message, if one has been provided. |
|
217 | + * |
|
218 | + * @return string |
|
219 | + */ |
|
220 | 220 | public function getSuccessMessage() : string |
221 | 221 | { |
222 | 222 | return $this->getMessage(self::TYPE_SUCCESS); |
@@ -232,21 +232,21 @@ discard block |
||
232 | 232 | return $this->getMessage(self::TYPE_WARNING); |
233 | 233 | } |
234 | 234 | |
235 | - /** |
|
236 | - * Whether a specific error/success code has been specified. |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
235 | + /** |
|
236 | + * Whether a specific error/success code has been specified. |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | 240 | public function hasCode() : bool |
241 | 241 | { |
242 | 242 | return $this->code > 0; |
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
246 | - * Retrieves the error/success code, if any. |
|
247 | - * |
|
248 | - * @return int The error code, or 0 if none. |
|
249 | - */ |
|
245 | + /** |
|
246 | + * Retrieves the error/success code, if any. |
|
247 | + * |
|
248 | + * @return int The error code, or 0 if none. |
|
249 | + */ |
|
250 | 250 | public function getCode() : int |
251 | 251 | { |
252 | 252 | return $this->code; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param string $message Should not contain a date, just the system specific info. |
145 | 145 | * @return $this |
146 | 146 | */ |
147 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
147 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
148 | 148 | { |
149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
150 | 150 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $message Should be as detailed as possible. |
156 | 156 | * @return $this |
157 | 157 | */ |
158 | - public function makeError(string $message, int $code=0) : OperationResult |
|
158 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
159 | 159 | { |
160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
161 | 161 | } |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | return $this->code; |
253 | 253 | } |
254 | 254 | |
255 | - public function getMessage(string $type='') : string |
|
255 | + public function getMessage(string $type = '') : string |
|
256 | 256 | { |
257 | - if(!empty($type)) |
|
257 | + if (!empty($type)) |
|
258 | 258 | { |
259 | - if($this->type === $type) |
|
259 | + if ($this->type === $type) |
|
260 | 260 | { |
261 | 261 | return $this->message; |
262 | 262 | } |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @throws ConvertHelper_Exception |
282 | 282 | */ |
283 | - public function makeException(Throwable $e, int $code=0, bool $withDeveloperInfo=false) : OperationResult |
|
283 | + public function makeException(Throwable $e, int $code = 0, bool $withDeveloperInfo = false) : OperationResult |
|
284 | 284 | { |
285 | 285 | $info = parseThrowable($e); |
286 | 286 | |
287 | - if($code === 0) |
|
287 | + if ($code === 0) |
|
288 | 288 | { |
289 | 289 | $code = $info->getCode(); |
290 | 290 | } |