Passed
Push — master ( f8e3f7...025a78 )
by Sebastian
03:51
created
src/Microtime.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
      * @see Microtime::createFromString()
115 115
      * @see Microtime::createNow()
116 116
      */
117
-    public function __construct($datetime=self::DATETIME_NOW, ?DateTimeZone $timeZone=null)
117
+    public function __construct($datetime = self::DATETIME_NOW, ?DateTimeZone $timeZone = null)
118 118
     {
119
-        if($datetime instanceof Microtime_ParseResult)
119
+        if ($datetime instanceof Microtime_ParseResult)
120 120
         {
121 121
             $parsed = $datetime;
122 122
         }
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      * @return Microtime_ParseResult
149 149
      * @throws Microtime_Exception
150 150
      */
151
-    private function parseDate($datetime, ?DateTimeZone $timeZone=null) : Microtime_ParseResult
151
+    private function parseDate($datetime, ?DateTimeZone $timeZone = null) : Microtime_ParseResult
152 152
     {
153
-        if($datetime instanceof Microtime)
153
+        if ($datetime instanceof Microtime)
154 154
         {
155 155
             return new Microtime_ParseResult(
156 156
                 $datetime->getISODate(),
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             );
159 159
         }
160 160
 
161
-        if($datetime instanceof DateTime)
161
+        if ($datetime instanceof DateTime)
162 162
         {
163 163
             return new Microtime_ParseResult(
164 164
                 $datetime->format(self::FORMAT_ISO),
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
             );
167 167
         }
168 168
 
169
-        if($timeZone === null)
169
+        if ($timeZone === null)
170 170
         {
171 171
             $timeZone = new DateTimeZone(date_default_timezone_get());
172 172
         }
173 173
 
174
-        if(empty($datetime) || $datetime === self::DATETIME_NOW)
174
+        if (empty($datetime) || $datetime === self::DATETIME_NOW)
175 175
         {
176 176
             return self::parseNow($timeZone);
177 177
         }
178 178
 
179
-        if(is_string($datetime))
179
+        if (is_string($datetime))
180 180
         {
181 181
             return new Microtime_ParseResult(
182 182
                 $datetime,
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         $dateObj = DateTime::createFromFormat('0.u00 U', microtime(), new DateTimeZone('America/Denver'));
205 205
 
206
-        if($dateObj !== false)
206
+        if ($dateObj !== false)
207 207
         {
208 208
             $dateObj->setTimezone($timeZone);
209 209
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
      * @return Microtime
228 228
      * @throws Microtime_Exception
229 229
      */
230
-    public static function createNow(?DateTimeZone $timeZone=null) : Microtime
230
+    public static function createNow(?DateTimeZone $timeZone = null) : Microtime
231 231
     {
232
-        if($timeZone === null)
232
+        if ($timeZone === null)
233 233
         {
234 234
             $timeZone = new DateTimeZone(date_default_timezone_get());
235 235
         }
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
      * @return Microtime
247 247
      * @throws Microtime_Exception
248 248
      */
249
-    public static function createFromString(string $date, ?DateTimeZone $timeZone=null) : Microtime
249
+    public static function createFromString(string $date, ?DateTimeZone $timeZone = null) : Microtime
250 250
     {
251
-        if($timeZone === null)
251
+        if ($timeZone === null)
252 252
         {
253 253
             $timeZone = new DateTimeZone(date_default_timezone_get());
254 254
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@  discard block
 block discarded – undo
119 119
         if($datetime instanceof Microtime_ParseResult)
120 120
         {
121 121
             $parsed = $datetime;
122
-        }
123
-        else
122
+        } else
124 123
         {
125 124
             $parsed = $this->parseDate($datetime, $timeZone);
126 125
         }
@@ -128,8 +127,7 @@  discard block
 block discarded – undo
128 127
         try
129 128
         {
130 129
             parent::__construct($parsed->getDateTime(), $parsed->getTimeZone());
131
-        }
132
-        catch (Exception $e)
130
+        } catch (Exception $e)
133 131
         {
134 132
             throw new Microtime_Exception(
135 133
                 'Failed to create date from string.',
Please login to merge, or discard this patch.
src/ConvertHelper/ThrowableInfo.php 3 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -30,48 +30,48 @@  discard block
 block discarded – undo
30 30
     const SERIALIZED_OPTIONS = 'options';
31 31
 
32 32
     /**
33
-    * @var Throwable
34
-    */
33
+     * @var Throwable
34
+     */
35 35
     protected $exception;
36 36
     
37
-   /**
38
-    * @var ConvertHelper_ThrowableInfo_Call[]
39
-    */
37
+    /**
38
+     * @var ConvertHelper_ThrowableInfo_Call[]
39
+     */
40 40
     protected $calls = array();
41 41
     
42
-   /**
43
-    * @var integer
44
-    */
42
+    /**
43
+     * @var integer
44
+     */
45 45
     protected $code = 0;
46 46
     
47
-   /**
48
-    * @var string
49
-    */
47
+    /**
48
+     * @var string
49
+     */
50 50
     protected $message;
51 51
     
52
-   /**
53
-    * @var integer
54
-    */
52
+    /**
53
+     * @var integer
54
+     */
55 55
     protected $callsCount = 0;
56 56
     
57
-   /**
58
-    * @var ConvertHelper_ThrowableInfo
59
-    */
57
+    /**
58
+     * @var ConvertHelper_ThrowableInfo
59
+     */
60 60
     protected $previous;
61 61
     
62
-   /**
63
-    * @var string
64
-    */
62
+    /**
63
+     * @var string
64
+     */
65 65
     protected $referer = '';
66 66
     
67
-   /**
68
-    * @var Microtime
69
-    */
67
+    /**
68
+     * @var Microtime
69
+     */
70 70
     protected $date;
71 71
     
72
-   /**
73
-    * @var string
74
-    */
72
+    /**
73
+     * @var string
74
+     */
75 75
     protected $context = self::CONTEXT_WEB;
76 76
 
77 77
     /**
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
         return isset($this->previous);
126 126
     }
127 127
     
128
-   /**
129
-    * Retrieves the information on the previous exception.
130
-    * 
131
-    * NOTE: Throws an exception if there is no previous 
132
-    * exception. Use hasPrevious() first to avoid this.
133
-    * 
134
-    * @throws ConvertHelper_Exception
135
-    * @return ConvertHelper_ThrowableInfo
136
-    * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
137
-    */
128
+    /**
129
+     * Retrieves the information on the previous exception.
130
+     * 
131
+     * NOTE: Throws an exception if there is no previous 
132
+     * exception. Use hasPrevious() first to avoid this.
133
+     * 
134
+     * @throws ConvertHelper_Exception
135
+     * @return ConvertHelper_ThrowableInfo
136
+     * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
137
+     */
138 138
     public function getPrevious() : ConvertHelper_ThrowableInfo
139 139
     {
140 140
         if(isset($this->previous)) {
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         return !empty($this->code);
154 154
     }
155 155
     
156
-   /**
157
-    * Improved text-only exception trace.
158
-    */
156
+    /**
157
+     * Improved text-only exception trace.
158
+     */
159 159
     public function toString() : string
160 160
     {
161 161
         $calls = $this->getCalls();
@@ -183,73 +183,73 @@  discard block
 block discarded – undo
183 183
         return $string;
184 184
     }
185 185
     
186
-   /**
187
-    * Retrieves the URL of the page in which the exception
188
-    * was thrown, if applicable: in CLI context, this will
189
-    * return an empty string.
190
-    * 
191
-    * @return string
192
-    */
186
+    /**
187
+     * Retrieves the URL of the page in which the exception
188
+     * was thrown, if applicable: in CLI context, this will
189
+     * return an empty string.
190
+     * 
191
+     * @return string
192
+     */
193 193
     public function getReferer() : string
194 194
     {
195 195
         return $this->referer;
196 196
     }
197 197
     
198
-   /**
199
-    * Whether the exception occurred in a command line context.
200
-    * @return bool
201
-    */
198
+    /**
199
+     * Whether the exception occurred in a command line context.
200
+     * @return bool
201
+     */
202 202
     public function isCommandLine() : bool
203 203
     {
204 204
         return $this->getContext() === self::CONTEXT_COMMAND_LINE;
205 205
     }
206 206
     
207
-   /**
208
-    * Whether the exception occurred during an http request.
209
-    * @return bool
210
-    */
207
+    /**
208
+     * Whether the exception occurred during an http request.
209
+     * @return bool
210
+     */
211 211
     public function isWebRequest() : bool
212 212
     {
213 213
         return $this->getContext() === self::CONTEXT_WEB;
214 214
     }
215 215
     
216
-   /**
217
-    * Retrieves the context identifier, i.e. if the exception
218
-    * occurred in a command line context or regular web request.
219
-    * 
220
-    * @return string
221
-    * 
222
-    * @see ConvertHelper_ThrowableInfo::isCommandLine()
223
-    * @see ConvertHelper_ThrowableInfo::isWebRequest()
224
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
225
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
226
-    */
216
+    /**
217
+     * Retrieves the context identifier, i.e. if the exception
218
+     * occurred in a command line context or regular web request.
219
+     * 
220
+     * @return string
221
+     * 
222
+     * @see ConvertHelper_ThrowableInfo::isCommandLine()
223
+     * @see ConvertHelper_ThrowableInfo::isWebRequest()
224
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
225
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
226
+     */
227 227
     public function getContext() : string
228 228
     {
229 229
         return $this->context;
230 230
     }
231 231
     
232
-   /**
233
-    * Retrieves the date of the exception, and approximate time:
234
-    * since exceptions do not store time, this is captured the 
235
-    * moment the ThrowableInfo is created.
236
-    * 
237
-    * @return Microtime
238
-    */
232
+    /**
233
+     * Retrieves the date of the exception, and approximate time:
234
+     * since exceptions do not store time, this is captured the 
235
+     * moment the ThrowableInfo is created.
236
+     * 
237
+     * @return Microtime
238
+     */
239 239
     public function getDate() : Microtime
240 240
     {
241 241
         return $this->date;
242 242
     }
243 243
     
244
-   /**
245
-    * Serializes all information on the exception to an
246
-    * associative array. This can be saved (file, database, 
247
-    * session...), and later be restored into a throwable
248
-    * info instance using the fromSerialized() method.
249
-    * 
250
-    * @return array<string,mixed>
251
-    * @see ConvertHelper_ThrowableInfo::fromSerialized()
252
-    */
244
+    /**
245
+     * Serializes all information on the exception to an
246
+     * associative array. This can be saved (file, database, 
247
+     * session...), and later be restored into a throwable
248
+     * info instance using the fromSerialized() method.
249
+     * 
250
+     * @return array<string,mixed>
251
+     * @see ConvertHelper_ThrowableInfo::fromSerialized()
252
+     */
253 253
     public function serialize() : array
254 254
     {
255 255
         $result = array(
@@ -276,24 +276,24 @@  discard block
 block discarded – undo
276 276
         return $result;
277 277
     }
278 278
 
279
-   /**
280
-    * Sets the maximum folder depth to show in the 
281
-    * file paths, to avoid them being too long.
282
-    * 
283
-    * @param int $depth
284
-    * @return ConvertHelper_ThrowableInfo
285
-    */
279
+    /**
280
+     * Sets the maximum folder depth to show in the 
281
+     * file paths, to avoid them being too long.
282
+     * 
283
+     * @param int $depth
284
+     * @return ConvertHelper_ThrowableInfo
285
+     */
286 286
     public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo
287 287
     {
288 288
         return $this->setOption('folder-depth', $depth);
289 289
     }
290 290
     
291
-   /**
292
-    * Retrieves the current folder depth option value.
293
-    * 
294
-    * @return int
295
-    * @see ConvertHelper_ThrowableInfo::setFolderDepth()
296
-    */
291
+    /**
292
+     * Retrieves the current folder depth option value.
293
+     * 
294
+     * @return int
295
+     * @see ConvertHelper_ThrowableInfo::setFolderDepth()
296
+     */
297 297
     public function getFolderDepth() : int
298 298
     {
299 299
         $depth = $this->getOption('folder-depth');
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
         return 2;
305 305
     }
306 306
     
307
-   /**
308
-    * Retrieves all function calls that led to the error,
309
-    * ordered from latest to earliest (the first one in
310
-    * the stack is actually the last call).
311
-    *
312
-    * @return ConvertHelper_ThrowableInfo_Call[]
313
-    */
307
+    /**
308
+     * Retrieves all function calls that led to the error,
309
+     * ordered from latest to earliest (the first one in
310
+     * the stack is actually the last call).
311
+     *
312
+     * @return ConvertHelper_ThrowableInfo_Call[]
313
+     */
314 314
     public function getCalls()
315 315
     {
316 316
         return $this->calls;
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
         return $this->calls[0];
327 327
     }
328 328
     
329
-   /**
330
-    * Returns the amount of function and method calls in the stack trace.
331
-    * @return int
332
-    */
329
+    /**
330
+     * Returns the amount of function and method calls in the stack trace.
331
+     * @return int
332
+     */
333 333
     public function countCalls() : int
334 334
     {
335 335
         return $this->callsCount;
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     protected function __construct($subject)
81 81
     {
82
-        if(is_array($subject))
82
+        if (is_array($subject))
83 83
         {
84 84
             $this->parseSerialized($subject);
85 85
         }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     */
138 138
     public function getPrevious() : ConvertHelper_ThrowableInfo
139 139
     {
140
-        if(isset($this->previous)) {
140
+        if (isset($this->previous)) {
141 141
             return $this->previous;
142 142
         }
143 143
         
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
         
163 163
         $string = 'Exception';
164 164
         
165
-        if($this->hasCode()) {
165
+        if ($this->hasCode()) {
166 166
             $string .= ' #'.$this->code;
167 167
         }
168 168
         
169 169
         $string .= ': '.$this->getMessage().PHP_EOL;
170 170
         
171
-        foreach($calls as $call) 
171
+        foreach ($calls as $call) 
172 172
         {
173 173
             $string .= $call->toString().PHP_EOL;
174 174
         }
175 175
         
176
-        if($this->hasPrevious())
176
+        if ($this->hasPrevious())
177 177
         {
178 178
             $string .= PHP_EOL.PHP_EOL.
179 179
             'Previous error:'.PHP_EOL.PHP_EOL.
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
             self::SERIALIZED_PREVIOUS => null,
265 265
         );
266 266
         
267
-        if($this->hasPrevious()) {
268
-            $result[self::SERIALIZED_PREVIOUS] =  $this->previous->serialize();
267
+        if ($this->hasPrevious()) {
268
+            $result[self::SERIALIZED_PREVIOUS] = $this->previous->serialize();
269 269
         }
270 270
         
271
-        foreach($this->calls as $call)
271
+        foreach ($this->calls as $call)
272 272
         {
273 273
             $result[self::SERIALIZED_CALLS][] = $call->serialize();
274 274
         }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     public function getFolderDepth() : int
298 298
     {
299 299
         $depth = $this->getOption('folder-depth');
300
-        if(!empty($depth)) {
300
+        if (!empty($depth)) {
301 301
             return $depth;
302 302
         }
303 303
         
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
         
354 354
         $this->setOptions($serialized[self::SERIALIZED_OPTIONS]);
355 355
         
356
-        if(!empty($serialized[self::SERIALIZED_PREVIOUS]))
356
+        if (!empty($serialized[self::SERIALIZED_PREVIOUS]))
357 357
         {
358 358
             $this->previous = ConvertHelper_ThrowableInfo::fromSerialized($serialized[self::SERIALIZED_PREVIOUS]);
359 359
         }
360 360
         
361
-        foreach($serialized[self::SERIALIZED_CALLS] as $def)
361
+        foreach ($serialized[self::SERIALIZED_CALLS] as $def)
362 362
         {
363 363
             $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def);
364 364
         }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
         $code = $e->getCode();
373 373
 
374
-        if(is_integer($code))
374
+        if (is_integer($code))
375 375
         {
376 376
             $this->code = $code;
377 377
         }
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
             $this->message = 'Original error code: ['.$code.']. ';
381 381
         }
382 382
 
383
-        if(!isset($_REQUEST['REQUEST_URI'])) {
383
+        if (!isset($_REQUEST['REQUEST_URI'])) {
384 384
             $this->context = self::CONTEXT_COMMAND_LINE;
385 385
         }
386 386
         
387 387
         $previous = $e->getPrevious();
388
-        if(!empty($previous)) {
388
+        if (!empty($previous)) {
389 389
             $this->previous = ConvertHelper::throwable2info($previous);
390 390
         }
391 391
         
392
-        if(isset($_SERVER['REQUEST_URI'])) {
392
+        if (isset($_SERVER['REQUEST_URI'])) {
393 393
             $this->referer = $_SERVER['REQUEST_URI'];
394 394
         }
395 395
         
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
         
404 404
         $idx = 1;
405 405
         
406
-        foreach($trace as $entry)
406
+        foreach ($trace as $entry)
407 407
         {
408 408
             $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromTrace($this, $idx, $entry);
409 409
             
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      * @return string
439 439
      * @throws ConvertHelper_Exception
440 440
      */
441
-    public function renderErrorMessage(bool $withDeveloperInfo=false) : string
441
+    public function renderErrorMessage(bool $withDeveloperInfo = false) : string
442 442
     {
443 443
         $finalCall = $this->getFinalCall();
444 444
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             ->t('Message:')
451 451
             ->add($this->getMessage());
452 452
 
453
-        if($withDeveloperInfo)
453
+        if ($withDeveloperInfo)
454 454
         {
455 455
             $message
456 456
             ->eol()
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             ->add($finalCall->toString());
459 459
         }
460 460
 
461
-        if($withDeveloperInfo && $this->hasDetails())
461
+        if ($withDeveloperInfo && $this->hasDetails())
462 462
         {
463 463
             $message
464 464
                 ->t('Developer details:')
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 
469 469
         $previous = $this->getPrevious();
470 470
 
471
-        if($previous !== null)
471
+        if ($previous !== null)
472 472
         {
473 473
             $message
474 474
                 ->eol()
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
     public function getDetails() : string
485 485
     {
486
-        if($this->exception instanceof BaseException)
486
+        if ($this->exception instanceof BaseException)
487 487
         {
488 488
             return $this->exception->getDetails();
489 489
         }
@@ -514,9 +514,9 @@  discard block
 block discarded – undo
514 514
             self::SERIALIZED_CALLS => 'array'
515 515
         );
516 516
 
517
-        foreach($keys as $key => $type)
517
+        foreach ($keys as $key => $type)
518 518
         {
519
-            if(!isset($serialized[$key]) || gettype($serialized[$key]) !== $type)
519
+            if (!isset($serialized[$key]) || gettype($serialized[$key]) !== $type)
520 520
             {
521 521
                 throw $this->createTypeException($key, $type);
522 522
             }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
         if(is_array($subject))
83 83
         {
84 84
             $this->parseSerialized($subject);
85
-        }
86
-        else
85
+        } else
87 86
         {
88 87
             $this->parseException($subject);
89 88
         }
@@ -374,8 +373,7 @@  discard block
 block discarded – undo
374 373
         if(is_integer($code))
375 374
         {
376 375
             $this->code = $code;
377
-        }
378
-        else
376
+        } else
379 377
         {
380 378
             $this->message = 'Original error code: ['.$code.']. ';
381 379
         }
Please login to merge, or discard this patch.