Passed
Push — 0.7.0 ( 418a4b...b5eec6 )
by Alexander
02:57
created
src/components/Debug/ExceptionHandler.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
         $caughtLength = $this->caughtLength = 0;
163 163
 
164
-        ob_start(function ($buffer) {
164
+        ob_start(function($buffer) {
165 165
 
166 166
             $this->caughtBuffer = $buffer;
167 167
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         if (isset($this->caughtBuffer[0]))
175 175
         {
176
-            ob_start(function ($buffer) {
176
+            ob_start(function($buffer) {
177 177
 
178 178
                 if ($this->caughtLength)
179 179
                 {
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
         if (is_string($frmt))
490 490
         {
491
-            $index  = strpos($f = $frmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l')) ?: strlen($f));
491
+            $index = strpos($f = $frmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l')) ?: strlen($f));
492 492
             $frmt = [substr($f, 0, $index)] + preg_split('/&([^>]++)>/', substr($f, $index), -1, PREG_SPLIT_DELIM_CAPTURE);
493 493
 
494 494
             for ($index = 1; isset($frmt[$index]); ++$index)
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -200,8 +200,7 @@  discard block
 block discarded – undo
200 200
         {
201 201
             ($this->handler)($exception);
202 202
             $caughtLength = $this->caughtLength;
203
-        }
204
-        catch (Exception $e)
203
+        } catch (Exception $e)
205 204
         {
206 205
             if ( ! $caughtLength)
207 206
             {
@@ -358,8 +357,7 @@  discard block
 block discarded – undo
358 357
 
359 358
                 $content .= "</table>\n</div>\n";
360 359
             }
361
-        }
362
-        catch (Exception $e)
360
+        } catch (Exception $e)
363 361
         {
364 362
             if ($this->debug)
365 363
             {
@@ -368,8 +366,7 @@  discard block
 block discarded – undo
368 366
                     $e->getClass(),
369 367
                     $this->escapeHtml($e->getMessage())
370 368
                 );
371
-            }
372
-            else
369
+            } else
373 370
             {
374 371
                 $title = 'Whoops, looks like something went wrong';
375 372
             }
@@ -501,14 +498,12 @@  discard block
 block discarded – undo
501 498
             }
502 499
 
503 500
             $data = strstr($frmt[0], ['%f' => $file, '%l' => $line]);
504
-        }
505
-        else
501
+        } else
506 502
         {
507 503
             try
508 504
             {
509 505
                 $data = $frmt->format($file, $line);
510
-            }
511
-            catch (Exception $e)
506
+            } catch (Exception $e)
512 507
             {
513 508
                 return sprintf('<span class="block trace-file-path">in <span title="%s%3$s"><strong>%s</strong>%s</span></span>', 
514 509
                         $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
@@ -535,24 +530,19 @@  discard block
 block discarded – undo
535 530
             if ($value[0] === 'object')
536 531
             {
537 532
                 $formatValue = sprintf('<em>(Object)</em>%s', $this->formatClass($value[1]));
538
-            }
539
-            elseif ($value[0] === 'array')
533
+            } elseif ($value[0] === 'array')
540 534
             {
541 535
                 $formatValue = sprintf('<em>(array)</em>%s', is_array($value[1]) ? $this->formatArgs($value[1]) : $value[1]);
542
-            }
543
-            elseif ($value[0] === 'null')
536
+            } elseif ($value[0] === 'null')
544 537
             {
545 538
                 $formatValue = '<em>Null</em>';
546
-            }
547
-            elseif ($value[0] === 'boolean')
539
+            } elseif ($value[0] === 'boolean')
548 540
             {
549 541
                 $formatValue = '<em>'.strtolower(var_export($value[1], true)).'</em>';
550
-            }
551
-            elseif ($value[0] === 'resource')
542
+            } elseif ($value[0] === 'resource')
552 543
             {
553 544
                 $formatValue = '<em>resource</em>';
554
-            }
555
-            else
545
+            } else
556 546
             {
557 547
                 $formatValue = str_replace("\n", '', $this->escapeHtml(var_export($value[1], true)));
558 548
             }
Please login to merge, or discard this patch.
src/components/Debug/GDebug.php 3 patches
Indentation   +409 added lines, -409 removed lines patch added patch discarded remove patch
@@ -42,428 +42,428 @@
 block discarded – undo
42 42
  */
43 43
 class GDebug implements DebugContract
44 44
 {
45
-	/**
46
-	 * Allow Handlers to force the script to quit.
47
-	 * 
48
-	 * @var bool $allowQuit
49
-	 */
50
-	protected $allowQuit = true;
45
+    /**
46
+     * Allow Handlers to force the script to quit.
47
+     * 
48
+     * @var bool $allowQuit
49
+     */
50
+    protected $allowQuit = true;
51 51
 	
52
-	/**
53
-	 * Benchmark instance.
54
-	 * 
55
-	 * @var string $benchmark
56
-	 */
57
-	protected $benchmark;
58
-
59
-	/**
60
-	 * The handler stack.
61
-	 * 
62
-	 * @var array $handlerStack
63
-	 */
64
-	protected $handlerStack = [];
65
-
66
-	/**
67
-	 * The send Http code by default: 500 Internal Server Error.
68
-	 * 
69
-	 * @var bool $sendHttpCode
70
-	 */
71
-	protected $sendHttpCode = 500;
72
-
73
-	/**
74
-	 * The send output.
75
-	 * 
76
-	 * @var bool $sendOutput
77
-	 */
78
-	protected $sendOutput = true;
79
-
80
-	/**
81
-	 * The functions of system what control errors and exceptions.
82
-	 * 
83
-	 * @var string $system
84
-	 */
85
-	protected $system;
86
-
87
-	/**
88
-	 * In certain scenarios, like in shutdown handler, we can not throw exceptions.
89
-	 * 
90
-	 * @var bool $throwExceptions
91
-	 */
92
-	protected $throwExceptions = true;
93
-
94
-	/**
95
-	 * Constructor. The Debug class instance.
96
-	 * 
97
-	 * @param  \Syscodes\Debug\Util\System|null  $system
98
-	 * 
99
-	 * @return void
100
-	 */
101
-	public function __construct(System $system = null)
102
-	{
103
-		$this->system    = $system ?: new System;
104
-		$this->benchmark = new Benchmark;
105
-	}
106
-
107
-	/**
108
-	 * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the 
109
-	 * error, display it if display_errors is on, and fire an event that allows custom actions 
110
-	 * to be taken at this point.
111
-	 *
112
-	 * @param  \Throwable  $exception
113
-	 *
114
-	 * @return string
115
-	 */
116
-	public function handleException(Throwable $exception)
117
-	{	
118
-		// The start benchmark
119
-		$this->benchmark->start('total_execution', LENEVOR_START);
120
-
121
-		$supervisor = $this->getSupervisor($exception);
122
-
123
-		// Start buffer
124
-		$this->system->startOutputBuferring();
125
-
126
-		$handlerResponse    = null;
127
-		$handlerContentType = null;
52
+    /**
53
+     * Benchmark instance.
54
+     * 
55
+     * @var string $benchmark
56
+     */
57
+    protected $benchmark;
58
+
59
+    /**
60
+     * The handler stack.
61
+     * 
62
+     * @var array $handlerStack
63
+     */
64
+    protected $handlerStack = [];
65
+
66
+    /**
67
+     * The send Http code by default: 500 Internal Server Error.
68
+     * 
69
+     * @var bool $sendHttpCode
70
+     */
71
+    protected $sendHttpCode = 500;
72
+
73
+    /**
74
+     * The send output.
75
+     * 
76
+     * @var bool $sendOutput
77
+     */
78
+    protected $sendOutput = true;
79
+
80
+    /**
81
+     * The functions of system what control errors and exceptions.
82
+     * 
83
+     * @var string $system
84
+     */
85
+    protected $system;
86
+
87
+    /**
88
+     * In certain scenarios, like in shutdown handler, we can not throw exceptions.
89
+     * 
90
+     * @var bool $throwExceptions
91
+     */
92
+    protected $throwExceptions = true;
93
+
94
+    /**
95
+     * Constructor. The Debug class instance.
96
+     * 
97
+     * @param  \Syscodes\Debug\Util\System|null  $system
98
+     * 
99
+     * @return void
100
+     */
101
+    public function __construct(System $system = null)
102
+    {
103
+        $this->system    = $system ?: new System;
104
+        $this->benchmark = new Benchmark;
105
+    }
106
+
107
+    /**
108
+     * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the 
109
+     * error, display it if display_errors is on, and fire an event that allows custom actions 
110
+     * to be taken at this point.
111
+     *
112
+     * @param  \Throwable  $exception
113
+     *
114
+     * @return string
115
+     */
116
+    public function handleException(Throwable $exception)
117
+    {	
118
+        // The start benchmark
119
+        $this->benchmark->start('total_execution', LENEVOR_START);
120
+
121
+        $supervisor = $this->getSupervisor($exception);
122
+
123
+        // Start buffer
124
+        $this->system->startOutputBuferring();
125
+
126
+        $handlerResponse    = null;
127
+        $handlerContentType = null;
128 128
 		
129
-		try 
130
-		{
131
-			foreach ($this->handlerStack as $handler)
132
-			{			
133
-				$handler->setDebug($this);
134
-				$handler->setException($exception);
135
-				$handler->setSupervisor($supervisor);
129
+        try 
130
+        {
131
+            foreach ($this->handlerStack as $handler)
132
+            {			
133
+                $handler->setDebug($this);
134
+                $handler->setException($exception);
135
+                $handler->setSupervisor($supervisor);
136 136
 				
137
-				$handlerResponse = $handler->handle();
137
+                $handlerResponse = $handler->handle();
138 138
 	
139
-				// Collect the content type for possible sending in the headers
140
-				$handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null;
139
+                // Collect the content type for possible sending in the headers
140
+                $handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null;
141 141
 	
142
-				if (in_array($handlerResponse, [MainHandler::LAST_HANDLER, MainHandler::QUIT]))
143
-				{
144
-					break;
145
-				}
146
-			}
142
+                if (in_array($handlerResponse, [MainHandler::LAST_HANDLER, MainHandler::QUIT]))
143
+                {
144
+                    break;
145
+                }
146
+            }
147 147
 	
148
-			$Quit = $handlerResponse == MainHandler::QUIT && $this->allowQuit();
149
-		}
150
-		finally
151
-		{
152
-			// Returns the contents of the output buffer
153
-			$output = $this->system->CleanOutputBuffer();	
154
-		}
155
-
156
-		// Returns the contents of the output buffer for loading time of page
157
-		$totalTime = $this->benchmark->getElapsedTime('total_execution');
158
-		$output    = str_replace('{elapsed_time}', $totalTime, $output);
159
-
160
-		if ($this->writeToOutput())
161
-		{
162
-			if ($Quit)
163
-			{
164
-				while ($this->system->getOutputBufferLevel() > 0) 
165
-				{
166
-					// Cleanes the output buffer
167
-					$this->system->endOutputBuffering();
168
-				}
169
-
170
-				if (Misc::sendHeaders() && $handlerContentType)
171
-				{
172
-					header("Content-Type: {$handlerContentType}");
173
-				}
174
-			}
175
-
176
-			$this->writeToOutputBuffer($output);
177
-		}
178
-
179
-		if ($Quit)
180
-		{
181
-			$this->system->flushOutputBuffer();
182
-			$this->system->stopException(1);
183
-		}
184
-
185
-		return $output;
186
-	}
187
-
188
-	/**
189
-	 * Allow Handlers to force the script to quit.
190
-	 * 
191
-	 * @param  bool|int  $exit
192
-	 * 
193
-	 * @return bool
194
-	 */
195
-	public function allowQuit($exit = null)
196
-	{
197
-		if (func_num_args() == 0)
198
-		{
199
-			return $this->allowQuit;
200
-		}
201
-
202
-		return $this->allowQuit = (bool) $exit;
203
-	}
204
-
205
-	/**
206
-	 * Lenevor Exception push output directly to the client it the data  
207
-	 * if they are true, but if it is false, the output will be returned 
208
-	 * by exception.
209
-	 * 
210
-	 * @param  bool|int  $send
211
-	 *
212
-	 * @return bool
213
-	 */
214
-	public function writeToOutput($send = null)
215
-	{
216
-		if (func_num_args() == 0)
217
-		{
218
-			return $this->sendOutput;
219
-		}
148
+            $Quit = $handlerResponse == MainHandler::QUIT && $this->allowQuit();
149
+        }
150
+        finally
151
+        {
152
+            // Returns the contents of the output buffer
153
+            $output = $this->system->CleanOutputBuffer();	
154
+        }
155
+
156
+        // Returns the contents of the output buffer for loading time of page
157
+        $totalTime = $this->benchmark->getElapsedTime('total_execution');
158
+        $output    = str_replace('{elapsed_time}', $totalTime, $output);
159
+
160
+        if ($this->writeToOutput())
161
+        {
162
+            if ($Quit)
163
+            {
164
+                while ($this->system->getOutputBufferLevel() > 0) 
165
+                {
166
+                    // Cleanes the output buffer
167
+                    $this->system->endOutputBuffering();
168
+                }
169
+
170
+                if (Misc::sendHeaders() && $handlerContentType)
171
+                {
172
+                    header("Content-Type: {$handlerContentType}");
173
+                }
174
+            }
175
+
176
+            $this->writeToOutputBuffer($output);
177
+        }
178
+
179
+        if ($Quit)
180
+        {
181
+            $this->system->flushOutputBuffer();
182
+            $this->system->stopException(1);
183
+        }
184
+
185
+        return $output;
186
+    }
187
+
188
+    /**
189
+     * Allow Handlers to force the script to quit.
190
+     * 
191
+     * @param  bool|int  $exit
192
+     * 
193
+     * @return bool
194
+     */
195
+    public function allowQuit($exit = null)
196
+    {
197
+        if (func_num_args() == 0)
198
+        {
199
+            return $this->allowQuit;
200
+        }
201
+
202
+        return $this->allowQuit = (bool) $exit;
203
+    }
204
+
205
+    /**
206
+     * Lenevor Exception push output directly to the client it the data  
207
+     * if they are true, but if it is false, the output will be returned 
208
+     * by exception.
209
+     * 
210
+     * @param  bool|int  $send
211
+     *
212
+     * @return bool
213
+     */
214
+    public function writeToOutput($send = null)
215
+    {
216
+        if (func_num_args() == 0)
217
+        {
218
+            return $this->sendOutput;
219
+        }
220 220
 		
221
-		return $this->sendOutput = (bool) $send;
222
-	}
221
+        return $this->sendOutput = (bool) $send;
222
+    }
223 223
 	
224
-	/**
225
-	 * Generate output to the browser.
226
-	 * 
227
-	 * @param  string  $output
228
-	 * 
229
-	 * @return $this
230
-	 */
231
-	protected function writeToOutputBuffer($output)
232
-	{
233
-		if ($this->sendHttpCode() && Misc::sendHeaders())
234
-		{
235
-			$this->system->setHttpResponseCode($this->sendHttpCode());
236
-		}
224
+    /**
225
+     * Generate output to the browser.
226
+     * 
227
+     * @param  string  $output
228
+     * 
229
+     * @return $this
230
+     */
231
+    protected function writeToOutputBuffer($output)
232
+    {
233
+        if ($this->sendHttpCode() && Misc::sendHeaders())
234
+        {
235
+            $this->system->setHttpResponseCode($this->sendHttpCode());
236
+        }
237 237
 		
238
-		echo $output;
238
+        echo $output;
239 239
 		
240
-		return $this;
241
-	}
242
-
243
-	/**
244
-	 * Error handler
245
-	 *
246
-	 * This will catch the php native error and treat it as a exception which will 
247
-	 * provide a full back trace on all errors.
248
-	 *
249
-	 * @param  int  $level
250
-	 * @param  string  $message
251
-	 * @param  string|null  $file
252
-	 * @param  int|null  $line
253
-	 *
254
-	 * @throws \ErrorException
255
-	 */
256
-	public function handleError(int $level, string $message, string $file = null, int $line = null)
257
-	{
258
-		if ($level & $this->system->getErrorReportingLevel()) 
259
-		{
260
-			$exception = new ErrorException($message, $level, $level, $file, $line);
261
-
262
-			if ($this->throwExceptions)
263
-			{
264
-				throw $exception;
265
-			}
266
-			else
267
-			{
268
-				$this->handleException($exception);
269
-			}
270
-
271
-			return true;
272
-		}
273
-
274
-		return false;
275
-	}
276
-
277
-	/**
278
-	 * Pushes a handler to the end of the stack.
279
-	 * 
280
-	 * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
281
-	 * 
282
-	 * @return \Syscodes\Contracts\Debug\Handler
283
-	 */
284
-	public function pushHandler($handler)
285
-	{
286
-		return $this->prependHandler($handler);
287
-	}
288
-
289
-	/**
290
-	 * Appends a handler to the end of the stack.
291
-	 * 
292
-	 * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
293
-	 * 
294
-	 * @return $this
295
-	 */
296
-	public function appendHandler($handler)
297
-	{
298
-		array_unshift($this->handlerStack, $this->resolveHandler($handler));
299
-
300
-		return $this;
301
-	}
302
-
303
-	/**
304
-	 * Prepends a handler to the start of the stack.
305
-	 * 
306
-	 * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
307
-	 * 
308
-	 * @return $this
309
-	 */
310
-	public function prependHandler($handler)
311
-	{
312
-		array_unshift($this->handlerStack, $this->resolveHandler($handler));
313
-
314
-		return $this;
315
-	}
316
-
317
-	/**
318
-	 * Create a CallbackHandler from callable and throw if handler is invalid.
319
-	 * 
320
-	 * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
321
-	 * 
322
-	 * @return \Syscodes\Contracts\Debug\Handler
323
-	 * 
324
-	 * @throws \InvalidArgumentException If argument is not callable or instance of \Syscodes\Contracts\Debug\Handler
325
-	 */
326
-	protected function resolveHandler($handler)
327
-	{
328
-		if (is_callable($handler))
329
-		{
330
-			$handler = new CallbackHandler($handler);
331
-		}
332
-
333
-		if ( ! $handler instanceof MainHandler) {
334
-			throw new InvalidArgumentException(
335
-				"Argument to " . __METHOD__ . " must be a callable, or instance of ".
336
-				"Syscodes\\Contracts\\Debug\\Handler"
337
-			);
338
-		}
339
-
340
-		return $handler;
341
-	}
342
-
343
-	/**
344
-	 * Returns an array with all handlers, in the order they were added to the stack.
345
-	 * 
346
-	 * @return array
347
-	 */
348
-	public function getHandlers()
349
-	{
350
-		return $this->handlerStack;
351
-	}
352
-
353
-	/**
354
-	 * Clears all handlers in the handlerStack, including the default PleasingPage handler.
355
-	 * 
356
-	 * @return $this
357
-	 */
358
-	public function clearHandlers()
359
-	{
360
-		$this->handlerStack = [];
361
-
362
-		return $this;
363
-	}
364
-
365
-	/**
366
-	 * Removes the last handler in the stack and returns it.
367
-	 * 
368
-	 * @return array|null
369
-	 */
370
-	public function popHandler()
371
-	{
372
-		return array_pop($this->handlerStack);
373
-	}
374
-
375
-	/**
376
-	 * Gets supervisor already specified.
377
-	 * 
378
-	 * @param  \Throwable  $exception
379
-	 * 
380
-	 * @return \Syscodes\Debug\Engine\Supervisor
381
-	 */
382
-	protected function getSupervisor(Throwable $exception)
383
-	{
384
-		return new Supervisor($exception);
385
-	}
386
-
387
-	/**
388
-	 * Unregisters all handlers registered by this Debug instance.
389
-	 * 
390
-	 * @return void
391
-	 */
392
-	public function off()
393
-	{
394
-		$this->system->restoreExceptionHandler();
395
-		$this->system->restoreErrorHandler();
396
-	}
240
+        return $this;
241
+    }
242
+
243
+    /**
244
+     * Error handler
245
+     *
246
+     * This will catch the php native error and treat it as a exception which will 
247
+     * provide a full back trace on all errors.
248
+     *
249
+     * @param  int  $level
250
+     * @param  string  $message
251
+     * @param  string|null  $file
252
+     * @param  int|null  $line
253
+     *
254
+     * @throws \ErrorException
255
+     */
256
+    public function handleError(int $level, string $message, string $file = null, int $line = null)
257
+    {
258
+        if ($level & $this->system->getErrorReportingLevel()) 
259
+        {
260
+            $exception = new ErrorException($message, $level, $level, $file, $line);
261
+
262
+            if ($this->throwExceptions)
263
+            {
264
+                throw $exception;
265
+            }
266
+            else
267
+            {
268
+                $this->handleException($exception);
269
+            }
270
+
271
+            return true;
272
+        }
273
+
274
+        return false;
275
+    }
276
+
277
+    /**
278
+     * Pushes a handler to the end of the stack.
279
+     * 
280
+     * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
281
+     * 
282
+     * @return \Syscodes\Contracts\Debug\Handler
283
+     */
284
+    public function pushHandler($handler)
285
+    {
286
+        return $this->prependHandler($handler);
287
+    }
288
+
289
+    /**
290
+     * Appends a handler to the end of the stack.
291
+     * 
292
+     * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
293
+     * 
294
+     * @return $this
295
+     */
296
+    public function appendHandler($handler)
297
+    {
298
+        array_unshift($this->handlerStack, $this->resolveHandler($handler));
299
+
300
+        return $this;
301
+    }
302
+
303
+    /**
304
+     * Prepends a handler to the start of the stack.
305
+     * 
306
+     * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
307
+     * 
308
+     * @return $this
309
+     */
310
+    public function prependHandler($handler)
311
+    {
312
+        array_unshift($this->handlerStack, $this->resolveHandler($handler));
313
+
314
+        return $this;
315
+    }
316
+
317
+    /**
318
+     * Create a CallbackHandler from callable and throw if handler is invalid.
319
+     * 
320
+     * @param  \Callable|\Syscodes\Contracts\Debug\Handler  $handler
321
+     * 
322
+     * @return \Syscodes\Contracts\Debug\Handler
323
+     * 
324
+     * @throws \InvalidArgumentException If argument is not callable or instance of \Syscodes\Contracts\Debug\Handler
325
+     */
326
+    protected function resolveHandler($handler)
327
+    {
328
+        if (is_callable($handler))
329
+        {
330
+            $handler = new CallbackHandler($handler);
331
+        }
332
+
333
+        if ( ! $handler instanceof MainHandler) {
334
+            throw new InvalidArgumentException(
335
+                "Argument to " . __METHOD__ . " must be a callable, or instance of ".
336
+                "Syscodes\\Contracts\\Debug\\Handler"
337
+            );
338
+        }
339
+
340
+        return $handler;
341
+    }
342
+
343
+    /**
344
+     * Returns an array with all handlers, in the order they were added to the stack.
345
+     * 
346
+     * @return array
347
+     */
348
+    public function getHandlers()
349
+    {
350
+        return $this->handlerStack;
351
+    }
352
+
353
+    /**
354
+     * Clears all handlers in the handlerStack, including the default PleasingPage handler.
355
+     * 
356
+     * @return $this
357
+     */
358
+    public function clearHandlers()
359
+    {
360
+        $this->handlerStack = [];
361
+
362
+        return $this;
363
+    }
364
+
365
+    /**
366
+     * Removes the last handler in the stack and returns it.
367
+     * 
368
+     * @return array|null
369
+     */
370
+    public function popHandler()
371
+    {
372
+        return array_pop($this->handlerStack);
373
+    }
374
+
375
+    /**
376
+     * Gets supervisor already specified.
377
+     * 
378
+     * @param  \Throwable  $exception
379
+     * 
380
+     * @return \Syscodes\Debug\Engine\Supervisor
381
+     */
382
+    protected function getSupervisor(Throwable $exception)
383
+    {
384
+        return new Supervisor($exception);
385
+    }
386
+
387
+    /**
388
+     * Unregisters all handlers registered by this Debug instance.
389
+     * 
390
+     * @return void
391
+     */
392
+    public function off()
393
+    {
394
+        $this->system->restoreExceptionHandler();
395
+        $this->system->restoreErrorHandler();
396
+    }
397 397
 	
398
-	/**
399
-	 * Registers this instance as an error handler.
400
-	 * 
401
-	 * @return void
402
-	 */
403
-	public function on() 
404
-	{
405
-		// Set the exception handler
406
-		$this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]);
407
-		// Set the error handler
408
-		$this->system->setErrorHandler([$this, self::ERROR_HANDLER]);
409
-		// Set the handler for shutdown to catch Parse errors
410
-		$this->system->registerShutdownFunction([$this, self::SHUTDOWN_HANDLER]);
411
-	}
412
-
413
-	/**
414
-	 * Lenevor Exception will by default send HTTP code 500, but you may wish
415
-	 * to use 502, 503, or another 5xx family code.
416
-	 * 
417
-	 * @param  bool|int  $code
418
-	 * 
419
-	 * @return int|false
420
-	 * 
421
-	 * @throws \InvalidArgumentException
422
-	 */
423
-	public function sendHttpCode($code = null)
424
-	{
425
-		if (func_num_args() == 0)
426
-		{
427
-			return $this->sendHttpCode;
428
-		}
398
+    /**
399
+     * Registers this instance as an error handler.
400
+     * 
401
+     * @return void
402
+     */
403
+    public function on() 
404
+    {
405
+        // Set the exception handler
406
+        $this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]);
407
+        // Set the error handler
408
+        $this->system->setErrorHandler([$this, self::ERROR_HANDLER]);
409
+        // Set the handler for shutdown to catch Parse errors
410
+        $this->system->registerShutdownFunction([$this, self::SHUTDOWN_HANDLER]);
411
+    }
412
+
413
+    /**
414
+     * Lenevor Exception will by default send HTTP code 500, but you may wish
415
+     * to use 502, 503, or another 5xx family code.
416
+     * 
417
+     * @param  bool|int  $code
418
+     * 
419
+     * @return int|false
420
+     * 
421
+     * @throws \InvalidArgumentException
422
+     */
423
+    public function sendHttpCode($code = null)
424
+    {
425
+        if (func_num_args() == 0)
426
+        {
427
+            return $this->sendHttpCode;
428
+        }
429 429
 		
430
-		if ( ! $code)
431
-		{
432
-			return $this->sendHttpCode = false;
433
-		}
430
+        if ( ! $code)
431
+        {
432
+            return $this->sendHttpCode = false;
433
+        }
434 434
 		
435
-		if ($code === true)
436
-		{
437
-			$code = 500;
438
-		}
435
+        if ($code === true)
436
+        {
437
+            $code = 500;
438
+        }
439 439
 		
440
-		if ($code < 400 || 600 <= $code)
441
-		{
442
-			throw new InvalidArgumentException("Invalid status code {$code}, must be 4xx or 5xx");
443
-		}
440
+        if ($code < 400 || 600 <= $code)
441
+        {
442
+            throw new InvalidArgumentException("Invalid status code {$code}, must be 4xx or 5xx");
443
+        }
444 444
 		
445
-		return $this->sendHttpCode = $code;
446
-	}
447
-
448
-	/**
449
-	 * This will catch errors that are generated at the shutdown level of execution.
450
-	 *
451
-	 * @return void
452
-	 *
453
-	 * @throws \ErrorException
454
-	 */
455
-	public function handleShutdown()
456
-	{
457
-		$this->throwExceptions = false;
458
-
459
-		$error = $this->system->getLastError();
460
-
461
-		// If we've got an error that hasn't been displayed, then convert
462
-		// it to an Exception and use the Exception handler to display it
463
-		// to the user
464
-		if ($error && Misc::isFatalError($error['type']))
465
-		{
466
-			$this->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
467
-		}
468
-	}
445
+        return $this->sendHttpCode = $code;
446
+    }
447
+
448
+    /**
449
+     * This will catch errors that are generated at the shutdown level of execution.
450
+     *
451
+     * @return void
452
+     *
453
+     * @throws \ErrorException
454
+     */
455
+    public function handleShutdown()
456
+    {
457
+        $this->throwExceptions = false;
458
+
459
+        $error = $this->system->getLastError();
460
+
461
+        // If we've got an error that hasn't been displayed, then convert
462
+        // it to an Exception and use the Exception handler to display it
463
+        // to the user
464
+        if ($error && Misc::isFatalError($error['type']))
465
+        {
466
+            $this->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
467
+        }
468
+    }
469 469
 }
470 470
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -332,7 +332,7 @@
 block discarded – undo
332 332
 
333 333
 		if ( ! $handler instanceof MainHandler) {
334 334
 			throw new InvalidArgumentException(
335
-				"Argument to " . __METHOD__ . " must be a callable, or instance of ".
335
+				"Argument to ".__METHOD__." must be a callable, or instance of ".
336 336
 				"Syscodes\\Contracts\\Debug\\Handler"
337 337
 			);
338 338
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -146,8 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 	
148 148
 			$Quit = $handlerResponse == MainHandler::QUIT && $this->allowQuit();
149
-		}
150
-		finally
149
+		} finally
151 150
 		{
152 151
 			// Returns the contents of the output buffer
153 152
 			$output = $this->system->CleanOutputBuffer();	
@@ -262,8 +261,7 @@  discard block
 block discarded – undo
262 261
 			if ($this->throwExceptions)
263 262
 			{
264 263
 				throw $exception;
265
-			}
266
-			else
264
+			} else
267 265
 			{
268 266
 				$this->handleException($exception);
269 267
 			}
Please login to merge, or discard this patch.
src/components/Debug/FatalExceptions/FatalThrowableError.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,12 +56,10 @@
 block discarded – undo
56 56
         if ($exception instanceof ParseError)
57 57
         {
58 58
             $severity = E_PARSE;
59
-        }
60
-        elseif ($exception instanceof TypeError)
59
+        } elseif ($exception instanceof TypeError)
61 60
         {
62 61
             $severity = E_RECOVERABLE_ERROR;
63
-        }
64
-        else
62
+        } else
65 63
         {
66 64
             $severity = E_ERROR;
67 65
         }
Please login to merge, or discard this patch.
src/components/Debug/FatalExceptions/FlattenException.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -219,13 +219,13 @@
 block discarded – undo
219 219
         return $this->file;
220 220
     }
221 221
 
222
-     /**
223
-     * Sets the file path.
224
-     * 
225
-     * @param  string  $file
226
-     * 
227
-     * @return $this
228
-     */
222
+        /**
223
+         * Sets the file path.
224
+         * 
225
+         * @param  string  $file
226
+         * 
227
+         * @return $this
228
+         */
229 229
     public function setFile($file)
230 230
     {
231 231
         $this->file = $file;
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -487,43 +487,34 @@
 block discarded – undo
487 487
             if ($value instanceof \__PHP_Incomplete_Class)
488 488
             {
489 489
                 $result[$key] = ['incomplete-object', $this->getClassNameFromIncomplete($value)];
490
-            }
491
-            elseif (is_object($value))
490
+            } elseif (is_object($value))
492 491
             {
493 492
                 $result[$key] = ['object', get_class($value)];
494
-            }
495
-            elseif (is_array($value))
493
+            } elseif (is_array($value))
496 494
             {
497 495
                 if ($level > 10)
498 496
                 {
499 497
                     $result[$key] = ['array', '*DEEP NESTED ARRAY*'];
500
-                }
501
-                else 
498
+                } else 
502 499
                 {
503 500
                     $result[$key] = ['array', $this->flattenArgs($value, $level + 1, $count)];
504 501
                 }
505
-            }
506
-            elseif ($value === null)
502
+            } elseif ($value === null)
507 503
             {
508 504
                 $result[$key] = ['null', null];
509
-            }
510
-            elseif (is_bool($value))
505
+            } elseif (is_bool($value))
511 506
             {
512 507
                 $result[$key] = ['boolean', $value];
513
-            }
514
-            elseif (is_int($value))
508
+            } elseif (is_int($value))
515 509
             {
516 510
                 $result[$key] = ['integer', $value];
517
-            }
518
-            elseif (is_float($value))
511
+            } elseif (is_float($value))
519 512
             {
520 513
                 $result[$key] = ['float', $value];
521
-            }
522
-            elseif (is_resource($value))
514
+            } elseif (is_resource($value))
523 515
             {
524 516
                 $result[$key] = ['resource', get_resource_type($value)];
525
-            }
526
-            else
517
+            } else
527 518
             {
528 519
                 $result[$key] = ['string', (string) $value];
529 520
             }
Please login to merge, or discard this patch.
src/components/Debug/FatalExceptions/FatalErrorException.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
             }
75 75
 
76 76
             $this->setTrace($trace);
77
-        }
78
-        elseif (null !== $traceOffset)
77
+        } elseif (null !== $traceOffset)
79 78
         {
80 79
             if (function_exists('xdebug_get_function_stack'))
81 80
             {
@@ -94,12 +93,10 @@  discard block
 block discarded – undo
94 93
                         {
95 94
                             $frame['type'] = '::';
96 95
                         }
97
-                    }
98
-                    elseif ('dynamic' === $frame['type'])
96
+                    } elseif ('dynamic' === $frame['type'])
99 97
                     {
100 98
                         $frame['type'] = '->';
101
-                    }
102
-                    elseif ('static' === $frame['type'])
99
+                    } elseif ('static' === $frame['type'])
103 100
                     {
104 101
                         $frame['type'] = '::';
105 102
                     }
@@ -107,8 +104,7 @@  discard block
 block discarded – undo
107 104
                     if ( ! $traceArgs)
108 105
                     {
109 106
                         unset($frame['params'], $frame['args']);
110
-                    }
111
-                    elseif (isset($frame['params']) && ! $frame['args'])
107
+                    } elseif (isset($frame['params']) && ! $frame['args'])
112 108
                     {
113 109
                         $frame['args'] = $frame['params'];
114 110
                         unset($frame['params']);
@@ -117,8 +113,7 @@  discard block
 block discarded – undo
117 113
                 
118 114
                 unset($frame);
119 115
                 $trace = array_reverse($trace);
120
-            }
121
-            else
116
+            } else
122 117
             {
123 118
                 $trace = [];
124 119
             }
Please login to merge, or discard this patch.
src/components/Events/EventServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
      */
40 40
     public function register()
41 41
     {
42
-        $this->app->singleton('events', function ($app) {
42
+        $this->app->singleton('events', function($app) {
43 43
             return new Dispatcher($app);
44 44
         });
45 45
     }
Please login to merge, or discard this patch.
src/components/Events/Dispatcher.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             return $this->createClassListener($listener, $wilcard);
137 137
         }
138 138
 
139
-        return function ($event, $payload) use ($listener, $wilcard) {
139
+        return function($event, $payload) use ($listener, $wilcard) {
140 140
 
141 141
             if ($wilcard)
142 142
             {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function createClassListener($listener, $wilcard = false)
160 160
     {
161
-        return function ($event, $payload) use ($listener, $wilcard) {
161
+        return function($event, $payload) use ($listener, $wilcard) {
162 162
 
163 163
             if ($wilcard)
164 164
             {
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@  discard block
 block discarded – undo
98 98
             if (Str::contains($event, '*'))
99 99
             {
100 100
                 $this->setupWilcardListen($event, $listener);
101
-            }
102
-            else
101
+            } else
103 102
             {
104 103
                 $this->listeners[$event][$priority][] = $this->makeListener($listener);
105 104
 
@@ -336,8 +335,7 @@  discard block
 block discarded – undo
336 335
         if (is_object($event))
337 336
         {
338 337
             list($payload, $event) = [[$event], getClass($event, false)];
339
-        }
340
-        elseif ( ! is_array($payload))
338
+        } elseif ( ! is_array($payload))
341 339
         {
342 340
             $payload = [$payload];
343 341
         }
@@ -422,8 +420,7 @@  discard block
 block discarded – undo
422 420
         if (Str::contains($event, '*'))
423 421
         {
424 422
             unset($this->wilcards[$event]);
425
-        }
426
-        else
423
+        } else
427 424
         {
428 425
             unset($this->listeners[$event], $this->sorted[$event]);
429 426
         }
Please login to merge, or discard this patch.
src/components/Collections/Arr.php 3 patches
Indentation   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -33,40 +33,40 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class Arr
35 35
 {
36
-	/**
37
-	 * Determine whether the value is accessible in a array.
38
-	 *
39
-	 * @param  mixed  $value The default value
40
-	 *
41
-	 * @return bool
42
-	 *
43
-	 * @uses   instanceof ArrayAccess
44
-	 */
45
-	public static function access($value) 
46
-	{
47
-		return is_array($value) || $value instanceof ArrayAccess;
48
-	}
49
-
50
-	/**
51
-	 * Add an element to an array using "dot" notation if it doesn't exist.
52
-	 *
53
-	 * @param  array  $array  The search array 
54
-	 * @param  string  $key  The key exist
55
-	 * @param  mixed  $value  The default value
56
-	 *
57
-	 * @return array 
58
-	 */
59
-	public static function add($array, $key, $value)
60
-	{
61
-		if (is_null(static::get($array, $key)))
62
-		{
63
-			static::set($array, $key, $value);
64
-		}
65
-
66
-		return $array;
67
-	}
68
-
69
-	/**
36
+    /**
37
+     * Determine whether the value is accessible in a array.
38
+     *
39
+     * @param  mixed  $value The default value
40
+     *
41
+     * @return bool
42
+     *
43
+     * @uses   instanceof ArrayAccess
44
+     */
45
+    public static function access($value) 
46
+    {
47
+        return is_array($value) || $value instanceof ArrayAccess;
48
+    }
49
+
50
+    /**
51
+     * Add an element to an array using "dot" notation if it doesn't exist.
52
+     *
53
+     * @param  array  $array  The search array 
54
+     * @param  string  $key  The key exist
55
+     * @param  mixed  $value  The default value
56
+     *
57
+     * @return array 
58
+     */
59
+    public static function add($array, $key, $value)
60
+    {
61
+        if (is_null(static::get($array, $key)))
62
+        {
63
+            static::set($array, $key, $value);
64
+        }
65
+
66
+        return $array;
67
+    }
68
+
69
+    /**
70 70
      * Collapse the collection items into a single array.
71 71
      * 
72 72
      * @return static
@@ -77,387 +77,387 @@  discard block
 block discarded – undo
77 77
 
78 78
         foreach ($array as $values)
79 79
         {
80
-			if ($values instanceof Collection)
81
-			{
82
-				$values = $values->all();
83
-			}
84
-			elseif ( ! is_array($values))
85
-			{
86
-				continue;
87
-			}
88
-
89
-			$results[] = $values;
80
+            if ($values instanceof Collection)
81
+            {
82
+                $values = $values->all();
83
+            }
84
+            elseif ( ! is_array($values))
85
+            {
86
+                continue;
87
+            }
88
+
89
+            $results[] = $values;
90 90
         }
91 91
 
92 92
         return array_merge([], ...$results);
93 93
     }
94 94
 
95
-	/**
96
-	 * Divide an array into two arrays. One with keys and the other with values.
97
-	 *
98
-	 * @param  array  $array
99
-	 *
100
-	 * @return array
101
-	 */
102
-	public static function divide($array)
103
-	{
104
-		return [array_keys($array), array_values($array)];
105
-	}
106
-
107
-	/**
108
-	 * Get all of the given array except for a specified array of items.
109
-	 *
110
-	 * @param  array  $array
111
-	 * @param  string|array  $keys
112
-	 *
113
-	 * @return array
114
-	 */
115
-	public static function except($array, $keys)
116
-	{
117
-		static::erase($array, $keys);
118
-
119
-		return $array;
120
-	}
95
+    /**
96
+     * Divide an array into two arrays. One with keys and the other with values.
97
+     *
98
+     * @param  array  $array
99
+     *
100
+     * @return array
101
+     */
102
+    public static function divide($array)
103
+    {
104
+        return [array_keys($array), array_values($array)];
105
+    }
106
+
107
+    /**
108
+     * Get all of the given array except for a specified array of items.
109
+     *
110
+     * @param  array  $array
111
+     * @param  string|array  $keys
112
+     *
113
+     * @return array
114
+     */
115
+    public static function except($array, $keys)
116
+    {
117
+        static::erase($array, $keys);
118
+
119
+        return $array;
120
+    }
121 121
 	
122
-	/**
123
-	 * Determine if the given key exists in the provided array.
124
-	 *
125
-	 * @param  ArrayAccess|array  $array  The search array
126
-	 * @param  string|int  $key  The key exist
127
-	 *
128
-	 * @return bool
129
-	 *
130
-	 * @uses   instaceof ArrayAccess
131
-	 */
132
-	public static function exists($array, $key) 
133
-	{
134
-		if ($array instanceof ArrayAccess) 
135
-		{
136
-			return $array->offsetExists($key);
137
-		}
122
+    /**
123
+     * Determine if the given key exists in the provided array.
124
+     *
125
+     * @param  ArrayAccess|array  $array  The search array
126
+     * @param  string|int  $key  The key exist
127
+     *
128
+     * @return bool
129
+     *
130
+     * @uses   instaceof ArrayAccess
131
+     */
132
+    public static function exists($array, $key) 
133
+    {
134
+        if ($array instanceof ArrayAccess) 
135
+        {
136
+            return $array->offsetExists($key);
137
+        }
138 138
 		
139
-		return array_key_exists($key, $array);
140
-	}
141
-
142
-	/**
143
-	 * Unsets dot-notated key from an array.
144
-	 *
145
-	 * @param  array  $array  The search array
146
-	 * @param  mixed  $keys  The dot-notated key or array of keys
147
-	 *
148
-	 * @return mixed
149
-	 */
150
-	public static function erase(&$array, $keys)
151
-	{
152
-		$original = &$array;
153
-
154
-		$keys = (array) $keys;
155
-
156
-		if (count($keys) === 0) 
157
-		{
158
-			return;
159
-		}
160
-
161
-		foreach ($keys as $key)
162
-		{
163
-			if (static::exists($array, $key))
164
-			{
165
-				unset($array[$key]);
166
-
167
-				continue;
168
-			}
139
+        return array_key_exists($key, $array);
140
+    }
141
+
142
+    /**
143
+     * Unsets dot-notated key from an array.
144
+     *
145
+     * @param  array  $array  The search array
146
+     * @param  mixed  $keys  The dot-notated key or array of keys
147
+     *
148
+     * @return mixed
149
+     */
150
+    public static function erase(&$array, $keys)
151
+    {
152
+        $original = &$array;
153
+
154
+        $keys = (array) $keys;
155
+
156
+        if (count($keys) === 0) 
157
+        {
158
+            return;
159
+        }
160
+
161
+        foreach ($keys as $key)
162
+        {
163
+            if (static::exists($array, $key))
164
+            {
165
+                unset($array[$key]);
166
+
167
+                continue;
168
+            }
169 169
 			
170
-			$parts = explode('.', $key);
170
+            $parts = explode('.', $key);
171 171
 
172
-			// Clean up after each pass
173
-			$array = &$original;
172
+            // Clean up after each pass
173
+            $array = &$original;
174 174
 	
175
-			// traverse the array into the second last key
176
-			while (count($parts) > 1) 
177
-			{
178
-				$part = array_shift($parts);
175
+            // traverse the array into the second last key
176
+            while (count($parts) > 1) 
177
+            {
178
+                $part = array_shift($parts);
179 179
 	
180
-				if (isset($array[$part]) && is_array($array[$part])) 
181
-				{
182
-					$array = &$array[$key];
183
-				}
184
-				else
185
-				{
186
-					continue 2;
187
-				}
188
-			}
189
-
190
-			unset($array[array_shift($parts)]);
191
-		}
192
-	}
193
-
194
-	/**
195
-	 * Flatten a multi-dimensional array into a single level.
196
-	 * 
197
-	 * @param  array  $array
198
-	 * 
199
-	 * @return array
200
-	 */
201
-	public static function flatten($array)
202
-	{
203
-		$result = [];
204
-
205
-		array_walk_recursive($array, function ($value) use (&$result) {
206
-			$result[] = $value;
207
-		});
208
-
209
-		return $result;
210
-	}
180
+                if (isset($array[$part]) && is_array($array[$part])) 
181
+                {
182
+                    $array = &$array[$key];
183
+                }
184
+                else
185
+                {
186
+                    continue 2;
187
+                }
188
+            }
189
+
190
+            unset($array[array_shift($parts)]);
191
+        }
192
+    }
193
+
194
+    /**
195
+     * Flatten a multi-dimensional array into a single level.
196
+     * 
197
+     * @param  array  $array
198
+     * 
199
+     * @return array
200
+     */
201
+    public static function flatten($array)
202
+    {
203
+        $result = [];
204
+
205
+        array_walk_recursive($array, function ($value) use (&$result) {
206
+            $result[] = $value;
207
+        });
208
+
209
+        return $result;
210
+    }
211 211
 	
212
-	/**
213
-	 * Fetch a flattened array of a nested array element.
214
-	 * 
215
-	 * @param  array  $array
216
-	 * @param  string  $key
217
-	 * 
218
-	 * @return array
219
-	 */
220
-	public static function fetch($array, $key)
221
-	{
222
-		foreach (explode('.', $key) as $segment)
223
-		{
224
-			$results = array();
212
+    /**
213
+     * Fetch a flattened array of a nested array element.
214
+     * 
215
+     * @param  array  $array
216
+     * @param  string  $key
217
+     * 
218
+     * @return array
219
+     */
220
+    public static function fetch($array, $key)
221
+    {
222
+        foreach (explode('.', $key) as $segment)
223
+        {
224
+            $results = array();
225 225
 			
226
-			foreach ($array as $value)
227
-			{
228
-				if (array_key_exists($segment, $value = (array) $value))
229
-				{
230
-					$results[] = $value[$segment];
231
-				}
232
-			}
226
+            foreach ($array as $value)
227
+            {
228
+                if (array_key_exists($segment, $value = (array) $value))
229
+                {
230
+                    $results[] = $value[$segment];
231
+                }
232
+            }
233 233
 			
234
-			$array = array_values($results);
235
-		}
234
+            $array = array_values($results);
235
+        }
236 236
 		
237
-		return array_values($results);
238
-	}
239
-
240
-	/**
241
-	 * Return the first element in an array passing a given truth test.
242
-	 *
243
-	 * @param  array  $array 
244
-	 * @param  \Closure  $callback
245
-	 * @param  mixed  $default  (null by default)
246
-	 *
247
-	 * @return mixed
248
-	 */
249
-	public static function first($array, callable $callback, $default = null)
250
-	{
251
-		foreach ($array as $key => $value)
252
-		{ 
253
-			if (call_user_func($callback, $key, $value)) return $value;
254
-		}
255
-
256
-		return value($default);
257
-	}	
258
-
259
-	/**
260
-	 * Get an item from an array using "dot" notation.
261
-	 *
262
-	 * @param  \ArrayAccess|array  $array  The search array
263
-	 * @param  string  $key  The dot-notated key or array of keys
264
-	 * @param  mixed  $default  The default value
265
-	 *
266
-	 * @return mixed
267
-	 */
268
-	public static function get($array, $key, $default = null)
269
-	{
270
-		if ( ! static::access($array))
271
-		{
272
-			return value($default);
273
-		}
274
-
275
-		if (static::exists($array, $key)) 
276
-		{
277
-			return $array[$key];
278
-		}
279
-
280
-		foreach (explode('.', $key) as $segm)
281
-		{
282
-			if (static::access($array) && static::exists($array, $segm))
283
-			{
284
-				$array = $array[$segm];
285
-			}
286
-			else
287
-			{
288
-				return value($default);
289
-			}
290
-		}
291
-
292
-		return $array;		
293
-	}
294
-
295
-	/**
296
-	 * Return the last element in an array passing a given truth test.
297
-	 *
298
-	 * @param  array  $array 
299
-	 * @param  \Closure  $callback
300
-	 * @param  mixed  $default 
301
-	 *
302
-	 * @return mixed
303
-	 *
304
-	 * @uses   \Syscodes\Support\Arr::first
305
-	 */
306
-	public static function last($array, $callback, $default = null)
307
-	{
308
-		return static::first(array_reverse($array), $callback, $default);
309
-	}
310
-
311
-	/**
312
-	 * Check if an item exists in an array using "dot" notation.
313
-	 * 
314
-	 * @param  array  $array
315
-	 * @param  string  $key
316
-	 * 
317
-	 * @return bool
318
-	 */
319
-	public static function has($array, $key)
320
-	{
321
-		if (empty($array) || is_null($key)) return false;
237
+        return array_values($results);
238
+    }
239
+
240
+    /**
241
+     * Return the first element in an array passing a given truth test.
242
+     *
243
+     * @param  array  $array 
244
+     * @param  \Closure  $callback
245
+     * @param  mixed  $default  (null by default)
246
+     *
247
+     * @return mixed
248
+     */
249
+    public static function first($array, callable $callback, $default = null)
250
+    {
251
+        foreach ($array as $key => $value)
252
+        { 
253
+            if (call_user_func($callback, $key, $value)) return $value;
254
+        }
255
+
256
+        return value($default);
257
+    }	
258
+
259
+    /**
260
+     * Get an item from an array using "dot" notation.
261
+     *
262
+     * @param  \ArrayAccess|array  $array  The search array
263
+     * @param  string  $key  The dot-notated key or array of keys
264
+     * @param  mixed  $default  The default value
265
+     *
266
+     * @return mixed
267
+     */
268
+    public static function get($array, $key, $default = null)
269
+    {
270
+        if ( ! static::access($array))
271
+        {
272
+            return value($default);
273
+        }
274
+
275
+        if (static::exists($array, $key)) 
276
+        {
277
+            return $array[$key];
278
+        }
279
+
280
+        foreach (explode('.', $key) as $segm)
281
+        {
282
+            if (static::access($array) && static::exists($array, $segm))
283
+            {
284
+                $array = $array[$segm];
285
+            }
286
+            else
287
+            {
288
+                return value($default);
289
+            }
290
+        }
291
+
292
+        return $array;		
293
+    }
294
+
295
+    /**
296
+     * Return the last element in an array passing a given truth test.
297
+     *
298
+     * @param  array  $array 
299
+     * @param  \Closure  $callback
300
+     * @param  mixed  $default 
301
+     *
302
+     * @return mixed
303
+     *
304
+     * @uses   \Syscodes\Support\Arr::first
305
+     */
306
+    public static function last($array, $callback, $default = null)
307
+    {
308
+        return static::first(array_reverse($array), $callback, $default);
309
+    }
310
+
311
+    /**
312
+     * Check if an item exists in an array using "dot" notation.
313
+     * 
314
+     * @param  array  $array
315
+     * @param  string  $key
316
+     * 
317
+     * @return bool
318
+     */
319
+    public static function has($array, $key)
320
+    {
321
+        if (empty($array) || is_null($key)) return false;
322 322
 		
323
-		if (array_key_exists($key, $array)) return true;
323
+        if (array_key_exists($key, $array)) return true;
324 324
 		
325
-		foreach (explode('.', $key) as $segment)
326
-		{
327
-			if ( ! is_array($array) || ! static::exists($array, $segment))
328
-			{
329
-				return false;
330
-			}
325
+        foreach (explode('.', $key) as $segment)
326
+        {
327
+            if ( ! is_array($array) || ! static::exists($array, $segment))
328
+            {
329
+                return false;
330
+            }
331 331
 			
332
-			$array = $array[$segment];
333
-		}
332
+            $array = $array[$segment];
333
+        }
334 334
 		
335
-		return true;
336
-	}
337
-
338
-	/**
339
-	 * Get a subset of the items from the given array.
340
-	 * 
341
-	 * @param  array  $array
342
-	 * @param  array|string  $keys
343
-	 * 
344
-	 * @return array
345
-	 */
346
-	public static function only($array, $keys)
347
-	{
348
-		return array_intersect_key($array, array_flip($array), $keys);
349
-	}
350
-
351
-	/**
352
-	 * Sets a value in an array using "dot" notation.
353
-	 *
354
-	 * @param  array  $array  The search array
355
-	 * @param  string  $key  The dot-notated key or array of keys
356
-	 * @param  mixed  $value  The default value
357
-	 *
358
-	 * @return mixed
359
-	 */
360
-	public static function set(& $array, $key, $value = null)
361
-	{
362
-		$keys = explode('.', $key);
363
-
364
-		while (count($keys) > 1)
365
-		{
366
-			$key = array_shift($keys);
367
-
368
-			if ( ! static::exists($array, $key))
369
-			{
370
-				$array[$key] = [];
371
-			}
372
-
373
-			$array =& $array[$key];
374
-		}
375
-
376
-		$array[array_shift($keys)] = $value;
377
-
378
-		return $array;
379
-	}
380
-
381
-	/**
382
-	 * Push an item onto the beginning of an array.
383
-	 * 
384
-	 * @param  mixed  $array
385
-	 * @param  mixed  $value
386
-	 * @param  mixed  key  (null by default)
387
-	 * 
388
-	 * @return array
389
-	 */
390
-	public static function prepend($array, $value, $key = null)
391
-	{
392
-		if (func_num_args() == 2)
393
-		{
394
-			array_unshift($array, $value);
395
-		}
396
-		else
397
-		{
398
-			$array = [$key => $value] + $array;
399
-		}
400
-
401
-		return $array;
402
-	}
403
-
404
-	/**
405
-	 * Get a value from the array, and remove it.
406
-	 * 
407
-	 * @param  array  $array
408
-	 * @param  string  $key
409
-	 * @param  mixed  $default  (null by default)
410
-	 * 
411
-	 * @return mixed
412
-	 */
413
-	public static function pull(&$array, $key, $default = null)
414
-	{
415
-		$value = static::get($array, $key, $default);
416
-
417
-		static::erase($array, $key);
418
-
419
-		return $value;
420
-	}
421
-
422
-	/**
423
-	 * Convert the array into a query string.
424
-	 * 
425
-	 * @param  array  $array
426
-	 * 
427
-	 * @return array
428
-	 */
429
-	public static function query($array)
430
-	{
431
-		return http_build_query($array, null, '&', PHP_QUERY_RFC3986);
432
-	}
433
-
434
-	/**
435
-	 * Filter the array using the given callback.
436
-	 * 
437
-	 * @param  array  $array
438
-	 * @param  \Callable  $callback
439
-	 * 
440
-	 * @return array
441
-	 */
442
-	public static function where($array, Callable $callback)
443
-	{
444
-		return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
445
-	}
446
-
447
-	/**
448
-	 * If the given value is not an array and not null, wrap it in one.
449
-	 * 
450
-	 * @param  mixed  $value
451
-	 * 
452
-	 * @return array
453
-	 */
454
-	public static function wrap($value)
455
-	{
456
-		if (is_null($value))
457
-		{
458
-			return [];
459
-		}
460
-
461
-		return is_array($value) ? $value : [$value];
462
-	}
335
+        return true;
336
+    }
337
+
338
+    /**
339
+     * Get a subset of the items from the given array.
340
+     * 
341
+     * @param  array  $array
342
+     * @param  array|string  $keys
343
+     * 
344
+     * @return array
345
+     */
346
+    public static function only($array, $keys)
347
+    {
348
+        return array_intersect_key($array, array_flip($array), $keys);
349
+    }
350
+
351
+    /**
352
+     * Sets a value in an array using "dot" notation.
353
+     *
354
+     * @param  array  $array  The search array
355
+     * @param  string  $key  The dot-notated key or array of keys
356
+     * @param  mixed  $value  The default value
357
+     *
358
+     * @return mixed
359
+     */
360
+    public static function set(& $array, $key, $value = null)
361
+    {
362
+        $keys = explode('.', $key);
363
+
364
+        while (count($keys) > 1)
365
+        {
366
+            $key = array_shift($keys);
367
+
368
+            if ( ! static::exists($array, $key))
369
+            {
370
+                $array[$key] = [];
371
+            }
372
+
373
+            $array =& $array[$key];
374
+        }
375
+
376
+        $array[array_shift($keys)] = $value;
377
+
378
+        return $array;
379
+    }
380
+
381
+    /**
382
+     * Push an item onto the beginning of an array.
383
+     * 
384
+     * @param  mixed  $array
385
+     * @param  mixed  $value
386
+     * @param  mixed  key  (null by default)
387
+     * 
388
+     * @return array
389
+     */
390
+    public static function prepend($array, $value, $key = null)
391
+    {
392
+        if (func_num_args() == 2)
393
+        {
394
+            array_unshift($array, $value);
395
+        }
396
+        else
397
+        {
398
+            $array = [$key => $value] + $array;
399
+        }
400
+
401
+        return $array;
402
+    }
403
+
404
+    /**
405
+     * Get a value from the array, and remove it.
406
+     * 
407
+     * @param  array  $array
408
+     * @param  string  $key
409
+     * @param  mixed  $default  (null by default)
410
+     * 
411
+     * @return mixed
412
+     */
413
+    public static function pull(&$array, $key, $default = null)
414
+    {
415
+        $value = static::get($array, $key, $default);
416
+
417
+        static::erase($array, $key);
418
+
419
+        return $value;
420
+    }
421
+
422
+    /**
423
+     * Convert the array into a query string.
424
+     * 
425
+     * @param  array  $array
426
+     * 
427
+     * @return array
428
+     */
429
+    public static function query($array)
430
+    {
431
+        return http_build_query($array, null, '&', PHP_QUERY_RFC3986);
432
+    }
433
+
434
+    /**
435
+     * Filter the array using the given callback.
436
+     * 
437
+     * @param  array  $array
438
+     * @param  \Callable  $callback
439
+     * 
440
+     * @return array
441
+     */
442
+    public static function where($array, Callable $callback)
443
+    {
444
+        return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
445
+    }
446
+
447
+    /**
448
+     * If the given value is not an array and not null, wrap it in one.
449
+     * 
450
+     * @param  mixed  $value
451
+     * 
452
+     * @return array
453
+     */
454
+    public static function wrap($value)
455
+    {
456
+        if (is_null($value))
457
+        {
458
+            return [];
459
+        }
460
+
461
+        return is_array($value) ? $value : [$value];
462
+    }
463 463
 }
464 464
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	{
203 203
 		$result = [];
204 204
 
205
-		array_walk_recursive($array, function ($value) use (&$result) {
205
+		array_walk_recursive($array, function($value) use (&$result) {
206 206
 			$result[] = $value;
207 207
 		});
208 208
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 				$array[$key] = [];
371 371
 			}
372 372
 
373
-			$array =& $array[$key];
373
+			$array = & $array[$key];
374 374
 		}
375 375
 
376 376
 		$array[array_shift($keys)] = $value;
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
 			if ($values instanceof Collection)
81 81
 			{
82 82
 				$values = $values->all();
83
-			}
84
-			elseif ( ! is_array($values))
83
+			} elseif ( ! is_array($values))
85 84
 			{
86 85
 				continue;
87 86
 			}
@@ -180,8 +179,7 @@  discard block
 block discarded – undo
180 179
 				if (isset($array[$part]) && is_array($array[$part])) 
181 180
 				{
182 181
 					$array = &$array[$key];
183
-				}
184
-				else
182
+				} else
185 183
 				{
186 184
 					continue 2;
187 185
 				}
@@ -250,7 +248,9 @@  discard block
 block discarded – undo
250 248
 	{
251 249
 		foreach ($array as $key => $value)
252 250
 		{ 
253
-			if (call_user_func($callback, $key, $value)) return $value;
251
+			if (call_user_func($callback, $key, $value)) {
252
+			    return $value;
253
+			}
254 254
 		}
255 255
 
256 256
 		return value($default);
@@ -282,8 +282,7 @@  discard block
 block discarded – undo
282 282
 			if (static::access($array) && static::exists($array, $segm))
283 283
 			{
284 284
 				$array = $array[$segm];
285
-			}
286
-			else
285
+			} else
287 286
 			{
288 287
 				return value($default);
289 288
 			}
@@ -318,9 +317,13 @@  discard block
 block discarded – undo
318 317
 	 */
319 318
 	public static function has($array, $key)
320 319
 	{
321
-		if (empty($array) || is_null($key)) return false;
320
+		if (empty($array) || is_null($key)) {
321
+		    return false;
322
+		}
322 323
 		
323
-		if (array_key_exists($key, $array)) return true;
324
+		if (array_key_exists($key, $array)) {
325
+		    return true;
326
+		}
324 327
 		
325 328
 		foreach (explode('.', $key) as $segment)
326 329
 		{
@@ -392,8 +395,7 @@  discard block
 block discarded – undo
392 395
 		if (func_num_args() == 2)
393 396
 		{
394 397
 			array_unshift($array, $value);
395
-		}
396
-		else
398
+		} else
397 399
 		{
398 400
 			$array = [$key => $value] + $array;
399 401
 		}
Please login to merge, or discard this patch.
src/components/Collections/Collection.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -275,11 +275,11 @@
 block discarded – undo
275 275
         return new static(array_combine($keys, $items));
276 276
     }
277 277
 
278
-     /**
279
-     * Reset the keys of the collection.
280
-     * 
281
-     * @return static
282
-     */
278
+        /**
279
+         * Reset the keys of the collection.
280
+         * 
281
+         * @return static
282
+         */
283 283
     public function keys()
284 284
     {
285 285
         return new static(array_keys($this->items));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             return array_search($value, $this->items, $strict);
525 525
         }
526 526
 
527
-        foreach($this->items as $key => $item)
527
+        foreach ($this->items as $key => $item)
528 528
         {
529 529
             if ($value($item, $key))
530 530
             {
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
         {
693 693
             return $items;
694 694
         }
695
-        elseif($items instanceof Arrayable)
695
+        elseif ($items instanceof Arrayable)
696 696
         {
697 697
             return $items->toArray();
698 698
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -203,8 +203,7 @@  discard block
 block discarded – undo
203 203
         if (is_null($callback))
204 204
         {
205 205
             return count($this->items) > 0 ? head($this->items) : null;
206
-        }
207
-        else
206
+        } else
208 207
         {
209 208
             return Arr::first($this->items, $callback, $default);
210 209
         }
@@ -691,16 +690,13 @@  discard block
 block discarded – undo
691 690
         if (is_array($items))
692 691
         {
693 692
             return $items;
694
-        }
695
-        elseif($items instanceof Arrayable)
693
+        } elseif($items instanceof Arrayable)
696 694
         {
697 695
             return $items->toArray();
698
-        }
699
-        elseif ($items instanceof Jsonable)
696
+        } elseif ($items instanceof Jsonable)
700 697
         {
701 698
             return json_decode($items->toJson(), true);
702
-        }
703
-        elseif ($items instanceof Collection)
699
+        } elseif ($items instanceof Collection)
704 700
         {
705 701
             return $items->all();
706 702
         }
@@ -783,8 +779,7 @@  discard block
 block discarded – undo
783 779
         if (is_null($offset))
784 780
         {
785 781
             $this->items[] = $value;
786
-        }
787
-        else
782
+        } else
788 783
         {
789 784
             $this->items[$offset] = $value;
790 785
         }
Please login to merge, or discard this patch.