Passed
Push — 0.7.0 ( 33914c...86b65d )
by Alexander
03:01
created
src/components/Debug/Exceptions/Util/TemplateHandler.php 3 patches
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -34,308 +34,308 @@
 block discarded – undo
34 34
  */
35 35
 class TemplateHandler
36 36
 {
37
-	/**
38
-	 * Benchmark instance.
39
-	 * 
40
-	 * @var string $benchmark
41
-	 */
42
-	protected $benchmark;
37
+    /**
38
+     * Benchmark instance.
39
+     * 
40
+     * @var string $benchmark
41
+     */
42
+    protected $benchmark;
43 43
 
44
-	/**
45
-	 * Nesting level of the output buffering mechanism.
46
-	 *
47
-	 * @var string $obLevel
48
-	 */
49
-	public $obLevel;
44
+    /**
45
+     * Nesting level of the output buffering mechanism.
46
+     *
47
+     * @var string $obLevel
48
+     */
49
+    public $obLevel;
50 50
 	
51
-	/**
52
-	 * The functions of system what control errors and exceptions.
53
-	 * 
54
-	 * @var string $system
55
-	 */
56
-	protected $system;
51
+    /**
52
+     * The functions of system what control errors and exceptions.
53
+     * 
54
+     * @var string $system
55
+     */
56
+    protected $system;
57 57
 	
58
-	/**
59
-	 * An array of variables to be passed to all templates.
60
-	 * 
61
-	 * @var array $variables
62
-	 */
63
-	protected $variables = [];
58
+    /**
59
+     * An array of variables to be passed to all templates.
60
+     * 
61
+     * @var array $variables
62
+     */
63
+    protected $variables = [];
64 64
 
65
-	/**
66
-	 * Constructor. The TemplateHandler class instance.
67
-	 * 
68
-	 * @return void
69
-	 */
70
-	public function __construct()
71
-	{
72
-		$this->system    = new System;
73
-		$this->benchmark = new Benchmark;
74
-		$this->obLevel   = $this->system->getOutputBufferLevel();
75
-	}
65
+    /**
66
+     * Constructor. The TemplateHandler class instance.
67
+     * 
68
+     * @return void
69
+     */
70
+    public function __construct()
71
+    {
72
+        $this->system    = new System;
73
+        $this->benchmark = new Benchmark;
74
+        $this->obLevel   = $this->system->getOutputBufferLevel();
75
+    }
76 76
 
77
-	/**
78
-	 * Clean Path: This makes nicer looking paths for the error output.
79
-	 *
80
-	 * @param  string  $file
81
-	 *
82
-	 * @return string
83
-	 */
84
-	public function cleanPath($file)
85
-	{
86
-		if (strpos($file, APP_PATH) === 0)
87
-		{
88
-			$file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH));
89
-		}
90
-		elseif (strpos($file, SYS_PATH) === 0)
91
-		{
92
-			$file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH));
93
-		}
94
-		elseif (strpos($file, CON_PATH) === 0)
95
-		{
96
-			$file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH));
97
-		}
98
-		elseif (strpos($file, RES_PATH) === 0)
99
-		{
100
-			$file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH));
101
-		}
77
+    /**
78
+     * Clean Path: This makes nicer looking paths for the error output.
79
+     *
80
+     * @param  string  $file
81
+     *
82
+     * @return string
83
+     */
84
+    public function cleanPath($file)
85
+    {
86
+        if (strpos($file, APP_PATH) === 0)
87
+        {
88
+            $file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH));
89
+        }
90
+        elseif (strpos($file, SYS_PATH) === 0)
91
+        {
92
+            $file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH));
93
+        }
94
+        elseif (strpos($file, CON_PATH) === 0)
95
+        {
96
+            $file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH));
97
+        }
98
+        elseif (strpos($file, RES_PATH) === 0)
99
+        {
100
+            $file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH));
101
+        }
102 102
 
103
-		return $file;
104
-	}
103
+        return $file;
104
+    }
105 105
 
106
-	/**
107
-	 * Display memory usage in real-world units. Intended for use
108
-	 * with memory_get_usage, etc.
109
-	 *
110
-	 * @param  int  $bytes
111
-	 *
112
-	 * @return string
113
-	 */
114
-	public function displayMemory(int $bytes)
115
-	{
116
-		if ($bytes < 1024)
117
-		{
118
-			return $bytes.'B';
119
-		}
120
-		else if ($bytes < 1048576)
121
-		{
122
-			return round($bytes/1024, 2).'KB';
123
-		}
106
+    /**
107
+     * Display memory usage in real-world units. Intended for use
108
+     * with memory_get_usage, etc.
109
+     *
110
+     * @param  int  $bytes
111
+     *
112
+     * @return string
113
+     */
114
+    public function displayMemory(int $bytes)
115
+    {
116
+        if ($bytes < 1024)
117
+        {
118
+            return $bytes.'B';
119
+        }
120
+        else if ($bytes < 1048576)
121
+        {
122
+            return round($bytes/1024, 2).'KB';
123
+        }
124 124
 
125
-		return round($bytes/1048576, 2).'MB';
126
-	}
125
+        return round($bytes/1048576, 2).'MB';
126
+    }
127 127
 	
128
-	/**
129
-	 * Format the given value into a human readable string.
130
-	 * 
131
-	 * @param  mixed  $value
132
-	 * 
133
-	 * @return string
134
-	 */
135
-	public function dump($value)
136
-	{
137
-		return htmlspecialchars(print_r($value, true));
138
-	}
128
+    /**
129
+     * Format the given value into a human readable string.
130
+     * 
131
+     * @param  mixed  $value
132
+     * 
133
+     * @return string
134
+     */
135
+    public function dump($value)
136
+    {
137
+        return htmlspecialchars(print_r($value, true));
138
+    }
139 139
 	
140
-	/**
141
-	 * Format the args of the given Frame as a human readable html string.
142
-	 * 
143
-	 * @param  \Syscodes\Debug\FrameHandler\Frame  $frame
144
-	 * 
145
-	 * @return string  The rendered html
146
-	 */
147
-	public function dumpArgs(Frame $frame)
148
-	{
149
-		$html      = '';
150
-		$numFrames = count($frame->getArgs());
140
+    /**
141
+     * Format the args of the given Frame as a human readable html string.
142
+     * 
143
+     * @param  \Syscodes\Debug\FrameHandler\Frame  $frame
144
+     * 
145
+     * @return string  The rendered html
146
+     */
147
+    public function dumpArgs(Frame $frame)
148
+    {
149
+        $html      = '';
150
+        $numFrames = count($frame->getArgs());
151 151
 		
152
-		if ($numFrames > 0)
153
-		{
154
-			$html = '<ol class="linenums">';
152
+        if ($numFrames > 0)
153
+        {
154
+            $html = '<ol class="linenums">';
155 155
 			
156
-			foreach ($frame->getArgs() as $j => $frameArg)
157
-			{
158
-				$html .= '<li>'.$this->dump($frameArg).'</li>';
159
-			}
156
+            foreach ($frame->getArgs() as $j => $frameArg)
157
+            {
158
+                $html .= '<li>'.$this->dump($frameArg).'</li>';
159
+            }
160 160
 			
161
-			$html .= '</ol>';
162
-		}
161
+            $html .= '</ol>';
162
+        }
163 163
 		
164
-		return $html;
165
-	}
164
+        return $html;
165
+    }
166 166
 
167
-	/**
168
-	 * Escapes a string for output in an HTML document.
169
-	 * 
170
-	 * @param  string  $text
171
-	 * 
172
-	 * @return string
173
-	 */
174
-	public function escape($text)
175
-	{
176
-		$flags = ENT_QUOTES;
167
+    /**
168
+     * Escapes a string for output in an HTML document.
169
+     * 
170
+     * @param  string  $text
171
+     * 
172
+     * @return string
173
+     */
174
+    public function escape($text)
175
+    {
176
+        $flags = ENT_QUOTES;
177 177
 		
178
-		// HHVM has all constants defined, but only ENT_IGNORE
179
-		// works at the moment
180
-		if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION"))
181
-		{
182
-			$flags |= ENT_SUBSTITUTE;
183
-		}
184
-		else
185
-		{
186
-			$flags |= ENT_IGNORE;
187
-		}
178
+        // HHVM has all constants defined, but only ENT_IGNORE
179
+        // works at the moment
180
+        if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION"))
181
+        {
182
+            $flags |= ENT_SUBSTITUTE;
183
+        }
184
+        else
185
+        {
186
+            $flags |= ENT_IGNORE;
187
+        }
188 188
 		
189
-		$text = str_replace(chr(9), '    ', $text);
189
+        $text = str_replace(chr(9), '    ', $text);
190 190
 		
191
-		return htmlspecialchars($text, $flags, "UTF-8");
192
-	}
191
+        return htmlspecialchars($text, $flags, "UTF-8");
192
+    }
193 193
 
194
-	/**
195
-	 * Returns all variables for this helper.
196
-	 * 
197
-	 * @return array
198
-	 */
199
-	public function getVariables()
200
-	{
201
-		return $this->variables;
202
-	}
194
+    /**
195
+     * Returns all variables for this helper.
196
+     * 
197
+     * @return array
198
+     */
199
+    public function getVariables()
200
+    {
201
+        return $this->variables;
202
+    }
203 203
 
204
-	/**
205
-	 * Creates a syntax-highlighted version of a PHP file.
206
-	 *
207
-	 * @param  string  $file
208
-	 * @param  int     $lineNumber
209
-	 * @param  int     $lines
210
-	 *
211
-	 * @return bool|string
212
-	 * 
213
-	 * @throws \Exception
214
-	 */
215
-	public function highlightFile($file, $lineNumber, $lines = 15)
216
-	{
217
-		if (empty ($file) || ! is_readable($file))
218
-		{
219
-			return false;
220
-		}
204
+    /**
205
+     * Creates a syntax-highlighted version of a PHP file.
206
+     *
207
+     * @param  string  $file
208
+     * @param  int     $lineNumber
209
+     * @param  int     $lines
210
+     *
211
+     * @return bool|string
212
+     * 
213
+     * @throws \Exception
214
+     */
215
+    public function highlightFile($file, $lineNumber, $lines = 15)
216
+    {
217
+        if (empty ($file) || ! is_readable($file))
218
+        {
219
+            return false;
220
+        }
221 221
 
222
-		// Set our highlight colors:
223
-		if (function_exists('ini_set'))
224
-		{
225
-			ini_set('highlight.comment', '#C5C5C5');
226
-			ini_set('highlight.default', '#5399BA');
227
-			ini_set('highlight.html', '#06B');
228
-			ini_set('highlight.keyword', '#7081A5;');
229
-			ini_set('highlight.string', '#d8A134');
230
-		}
222
+        // Set our highlight colors:
223
+        if (function_exists('ini_set'))
224
+        {
225
+            ini_set('highlight.comment', '#C5C5C5');
226
+            ini_set('highlight.default', '#5399BA');
227
+            ini_set('highlight.html', '#06B');
228
+            ini_set('highlight.keyword', '#7081A5;');
229
+            ini_set('highlight.string', '#d8A134');
230
+        }
231 231
 
232
-		try
233
-		{
234
-			$origin = file_get_contents($file);
235
-		}
236
-		catch (Exception $e)
237
-		{
238
-			return false;
239
-		}
232
+        try
233
+        {
234
+            $origin = file_get_contents($file);
235
+        }
236
+        catch (Exception $e)
237
+        {
238
+            return false;
239
+        }
240 240
 
241
-		$origin  = str_replace(["\r\n", "\r"], "\n", $origin);
242
-		$origin  = explode("\n", highlight_string($origin , true));
243
-		$origin  = str_replace('<br />', "\n", $origin [1]);
241
+        $origin  = str_replace(["\r\n", "\r"], "\n", $origin);
242
+        $origin  = explode("\n", highlight_string($origin , true));
243
+        $origin  = str_replace('<br />', "\n", $origin [1]);
244 244
 
245
-		$origin  = explode("\n", str_replace("\r\n", "\n", $origin));
245
+        $origin  = explode("\n", str_replace("\r\n", "\n", $origin));
246 246
 
247
-		// Get just the part to show
248
-		$start = $lineNumber - (int)round($lines / 2);
249
-		$start = $start < 0 ? 0 : $start;
247
+        // Get just the part to show
248
+        $start = $lineNumber - (int)round($lines / 2);
249
+        $start = $start < 0 ? 0 : $start;
250 250
 
251
-		// Get just the lines we need to display, while keeping line numbers...
252
-		$origin  = array_splice($origin, $start, $lines, true);
251
+        // Get just the lines we need to display, while keeping line numbers...
252
+        $origin  = array_splice($origin, $start, $lines, true);
253 253
 
254
-		// Used to format the line number in the source
255
-		$format = '% '.strlen($start + $lines).'d';
254
+        // Used to format the line number in the source
255
+        $format = '% '.strlen($start + $lines).'d';
256 256
 
257
-		$out = '';
258
-		// Because the highlighting may have an uneven number
259
-		// of open and close span tags on one line, we need
260
-		// to ensure we can close them all to get the lines
261
-		// showing correctly.
262
-		$spans = 1;
257
+        $out = '';
258
+        // Because the highlighting may have an uneven number
259
+        // of open and close span tags on one line, we need
260
+        // to ensure we can close them all to get the lines
261
+        // showing correctly.
262
+        $spans = 1;
263 263
 
264
-		foreach ($origin as $n => $row)
265
-		{
266
-			$spans += substr_count($row, '<span') - substr_count($row, '</span');
267
-			$row = str_replace(["\r", "\n"], ['', ''], $row);
264
+        foreach ($origin as $n => $row)
265
+        {
266
+            $spans += substr_count($row, '<span') - substr_count($row, '</span');
267
+            $row = str_replace(["\r", "\n"], ['', ''], $row);
268 268
 
269
-			if (($n+$start+1) == $lineNumber)
270
-			{
271
-				preg_match_all('#<[^>]+>#', $row, $tags);
272
-				$out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
273
-						$n + $start + 1,
274
-						strip_tags($row),
275
-						implode('', $tags[0])
276
-				);
277
-			}
278
-			else
279
-			{
280
-				$out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n";
281
-			}
282
-		}
269
+            if (($n+$start+1) == $lineNumber)
270
+            {
271
+                preg_match_all('#<[^>]+>#', $row, $tags);
272
+                $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
273
+                        $n + $start + 1,
274
+                        strip_tags($row),
275
+                        implode('', $tags[0])
276
+                );
277
+            }
278
+            else
279
+            {
280
+                $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n";
281
+            }
282
+        }
283 283
 
284
-		$out .= str_repeat('</span>', $spans);
284
+        $out .= str_repeat('</span>', $spans);
285 285
 
286
-		return '<pre class="code-blocks"><code>'.$out.'</code></pre>';
287
-	}
286
+        return '<pre class="code-blocks"><code>'.$out.'</code></pre>';
287
+    }
288 288
 
289
-	/**
290
-	 * Sets the variables to be passed to all templates rendered 
291
-	 * by this template helper.
292
-	 * 
293
-	 * @param  array  $variables
294
-	 * 
295
-	 * @return void
296
-	 */
297
-	public function setVariables(array $variables)
298
-	{
299
-		$this->variables = $variables;
300
-	}
289
+    /**
290
+     * Sets the variables to be passed to all templates rendered 
291
+     * by this template helper.
292
+     * 
293
+     * @param  array  $variables
294
+     * 
295
+     * @return void
296
+     */
297
+    public function setVariables(array $variables)
298
+    {
299
+        $this->variables = $variables;
300
+    }
301 301
 
302
-	/**
303
-	 * Convert a string to a slug version of itself.
304
-	 * 
305
-	 * @param  string  $original
306
-	 * 
307
-	 * @return string
308
-	 */
309
-	public function slug($original)
310
-	{
311
-		$slug = str_replace(" ", "-", $original);
312
-		$slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug);
302
+    /**
303
+     * Convert a string to a slug version of itself.
304
+     * 
305
+     * @param  string  $original
306
+     * 
307
+     * @return string
308
+     */
309
+    public function slug($original)
310
+    {
311
+        $slug = str_replace(" ", "-", $original);
312
+        $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug);
313 313
 
314
-		return strtolower($slug);
315
-	}
314
+        return strtolower($slug);
315
+    }
316 316
 
317
-	/**
318
-	 * Given an exception and status code will display the error to the client.
319
-	 *
320
-	 * @param  string  $template
321
-	 * 
322
-	 * @return void
323
-	 */
324
-	public function render($template)
325
-	{
326
-		$vars = $this->getVariables();
317
+    /**
318
+     * Given an exception and status code will display the error to the client.
319
+     *
320
+     * @param  string  $template
321
+     * 
322
+     * @return void
323
+     */
324
+    public function render($template)
325
+    {
326
+        $vars = $this->getVariables();
327 327
 
328
-		$vars['template'] = $this;
328
+        $vars['template'] = $this;
329 329
 		
330
-		if ($this->system->getOutputBufferLevel() > $this->obLevel + 1)
331
-		{
332
-			@$this->system->endOutputBuffering();
333
-		}
330
+        if ($this->system->getOutputBufferLevel() > $this->obLevel + 1)
331
+        {
332
+            @$this->system->endOutputBuffering();
333
+        }
334 334
 
335
-		// Instantiate the error view and prepare the vars
336
-		call_user_func(function () {
337
-			extract(func_get_arg(1));
338
-			include func_get_arg(0);
339
-		}, $template, $vars);
340
-	}
335
+        // Instantiate the error view and prepare the vars
336
+        call_user_func(function () {
337
+            extract(func_get_arg(1));
338
+            include func_get_arg(0);
339
+        }, $template, $vars);
340
+    }
341 341
 }
342 342
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 		}
120 120
 		else if ($bytes < 1048576)
121 121
 		{
122
-			return round($bytes/1024, 2).'KB';
122
+			return round($bytes / 1024, 2).'KB';
123 123
 		}
124 124
 
125
-		return round($bytes/1048576, 2).'MB';
125
+		return round($bytes / 1048576, 2).'MB';
126 126
 	}
127 127
 	
128 128
 	/**
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 		}
240 240
 
241 241
 		$origin  = str_replace(["\r\n", "\r"], "\n", $origin);
242
-		$origin  = explode("\n", highlight_string($origin , true));
242
+		$origin  = explode("\n", highlight_string($origin, true));
243 243
 		$origin  = str_replace('<br />', "\n", $origin [1]);
244 244
 
245 245
 		$origin  = explode("\n", str_replace("\r\n", "\n", $origin));
246 246
 
247 247
 		// Get just the part to show
248
-		$start = $lineNumber - (int)round($lines / 2);
248
+		$start = $lineNumber - (int) round($lines / 2);
249 249
 		$start = $start < 0 ? 0 : $start;
250 250
 
251 251
 		// Get just the lines we need to display, while keeping line numbers...
252
-		$origin  = array_splice($origin, $start, $lines, true);
252
+		$origin = array_splice($origin, $start, $lines, true);
253 253
 
254 254
 		// Used to format the line number in the source
255 255
 		$format = '% '.strlen($start + $lines).'d';
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 			$spans += substr_count($row, '<span') - substr_count($row, '</span');
267 267
 			$row = str_replace(["\r", "\n"], ['', ''], $row);
268 268
 
269
-			if (($n+$start+1) == $lineNumber)
269
+			if (($n + $start + 1) == $lineNumber)
270 270
 			{
271 271
 				preg_match_all('#<[^>]+>#', $row, $tags);
272 272
 				$out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 			else
279 279
 			{
280
-				$out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n";
280
+				$out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row)."\n";
281 281
 			}
282 282
 		}
283 283
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	public function slug($original)
310 310
 	{
311 311
 		$slug = str_replace(" ", "-", $original);
312
-		$slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug);
312
+		$slug = preg_replace('/[^\w\d\-\_]/i', ' ', $slug);
313 313
 
314 314
 		return strtolower($slug);
315 315
 	}
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		}
334 334
 
335 335
 		// Instantiate the error view and prepare the vars
336
-		call_user_func(function () {
336
+		call_user_func(function() {
337 337
 			extract(func_get_arg(1));
338 338
 			include func_get_arg(0);
339 339
 		}, $template, $vars);
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -86,16 +86,13 @@  discard block
 block discarded – undo
86 86
 		if (strpos($file, APP_PATH) === 0)
87 87
 		{
88 88
 			$file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH));
89
-		}
90
-		elseif (strpos($file, SYS_PATH) === 0)
89
+		} elseif (strpos($file, SYS_PATH) === 0)
91 90
 		{
92 91
 			$file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH));
93
-		}
94
-		elseif (strpos($file, CON_PATH) === 0)
92
+		} elseif (strpos($file, CON_PATH) === 0)
95 93
 		{
96 94
 			$file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH));
97
-		}
98
-		elseif (strpos($file, RES_PATH) === 0)
95
+		} elseif (strpos($file, RES_PATH) === 0)
99 96
 		{
100 97
 			$file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH));
101 98
 		}
@@ -116,8 +113,7 @@  discard block
 block discarded – undo
116 113
 		if ($bytes < 1024)
117 114
 		{
118 115
 			return $bytes.'B';
119
-		}
120
-		else if ($bytes < 1048576)
116
+		} else if ($bytes < 1048576)
121 117
 		{
122 118
 			return round($bytes/1024, 2).'KB';
123 119
 		}
@@ -180,8 +176,7 @@  discard block
 block discarded – undo
180 176
 		if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION"))
181 177
 		{
182 178
 			$flags |= ENT_SUBSTITUTE;
183
-		}
184
-		else
179
+		} else
185 180
 		{
186 181
 			$flags |= ENT_IGNORE;
187 182
 		}
@@ -232,8 +227,7 @@  discard block
 block discarded – undo
232 227
 		try
233 228
 		{
234 229
 			$origin = file_get_contents($file);
235
-		}
236
-		catch (Exception $e)
230
+		} catch (Exception $e)
237 231
 		{
238 232
 			return false;
239 233
 		}
@@ -274,8 +268,7 @@  discard block
 block discarded – undo
274 268
 						strip_tags($row),
275 269
 						implode('', $tags[0])
276 270
 				);
277
-			}
278
-			else
271
+			} else
279 272
 			{
280 273
 				$out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n";
281 274
 			}
Please login to merge, or discard this patch.
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.