Passed
Push — 0.7.0 ( 8420c9...9eca06 )
by Alexander
03:11 queued 10s
created
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.
src/components/Filesystem/FileMimeType.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,66 +31,66 @@
 block discarded – undo
31 31
  */
32 32
 class FileMimeType
33 33
 {
34
-	/**
35
-	 * Map of extensions to mime types.
36
-	 *
37
-	 * @var array $mimes
38
-	 */
39
-	public static $mimes = [];
34
+    /**
35
+     * Map of extensions to mime types.
36
+     *
37
+     * @var array $mimes
38
+     */
39
+    public static $mimes = [];
40 40
 
41
-	/**
42
-	 * Constructor with an optional verification that the path is 
43
-	 * really a mimes.
44
-	 *
45
-	 * @return mixed
46
-	 */
47
-	public function __construct()
48
-	{
49
-		static::$mimes = (array) require CON_PATH.'mimes.php';
50
-	}
41
+    /**
42
+     * Constructor with an optional verification that the path is 
43
+     * really a mimes.
44
+     *
45
+     * @return mixed
46
+     */
47
+    public function __construct()
48
+    {
49
+        static::$mimes = (array) require CON_PATH.'mimes.php';
50
+    }
51 51
 
52
-	/**
53
-	 * Attempts to determine the best mime type for the given file extension.
54
-	 *
55
-	 * @param  string  $extension
56
-	 *
57
-	 * @return string|null  The mime type found, or none if unable to determine
58
-	 */
59
-	public static function guessTypeFromExtension($extension)
60
-	{
61
-		$extension = trim(strtolower($extension), '. ');
52
+    /**
53
+     * Attempts to determine the best mime type for the given file extension.
54
+     *
55
+     * @param  string  $extension
56
+     *
57
+     * @return string|null  The mime type found, or none if unable to determine
58
+     */
59
+    public static function guessTypeFromExtension($extension)
60
+    {
61
+        $extension = trim(strtolower($extension), '. ');
62 62
 
63
-		if ( ! array_key_exists($extension, static::$mimes))
64
-		{
65
-			return null;
66
-		}
63
+        if ( ! array_key_exists($extension, static::$mimes))
64
+        {
65
+            return null;
66
+        }
67 67
 		
68
-		return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
69
-	}
68
+        return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
69
+    }
70 70
 
71
-	/**
72
-	 * Attempts to determine the best file extension for a given mime type.
73
-	 *
74
-	 * @param  string  $type
75
-	 *
76
-	 * @return string|null The extension determined, or null if unable to match
77
-	 */
78
-	public static function guessExtensionFromType($type)
79
-	{
80
-		$type = trim(strtolower($type), '. ');
71
+    /**
72
+     * Attempts to determine the best file extension for a given mime type.
73
+     *
74
+     * @param  string  $type
75
+     *
76
+     * @return string|null The extension determined, or null if unable to match
77
+     */
78
+    public static function guessExtensionFromType($type)
79
+    {
80
+        $type = trim(strtolower($type), '. ');
81 81
 
82
-		foreach (static::$mimes as $ext => $types)
83
-		{
84
-			if (is_string($types) && $types == $type)
85
-			{
86
-				return $ext;
87
-			}
88
-			else if (is_array($types) && in_array($type, $types))
89
-			{
90
-				return $ext;
91
-			}
92
-		}
82
+        foreach (static::$mimes as $ext => $types)
83
+        {
84
+            if (is_string($types) && $types == $type)
85
+            {
86
+                return $ext;
87
+            }
88
+            else if (is_array($types) && in_array($type, $types))
89
+            {
90
+                return $ext;
91
+            }
92
+        }
93 93
 
94
-		return null;
95
-	}
94
+        return null;
95
+    }
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,8 +84,7 @@
 block discarded – undo
84 84
 			if (is_string($types) && $types == $type)
85 85
 			{
86 86
 				return $ext;
87
-			}
88
-			else if (is_array($types) && in_array($type, $types))
87
+			} else if (is_array($types) && in_array($type, $types))
89 88
 			{
90 89
 				return $ext;
91 90
 			}
Please login to merge, or discard this patch.
src/components/Filesystem/Filesystem.php 3 patches
Indentation   +856 added lines, -856 removed lines patch added patch discarded remove patch
@@ -36,868 +36,868 @@
 block discarded – undo
36 36
  */
37 37
 class Filesystem 
38 38
 {
39
-	/**
40
-	 * Enable locking for file reading and writing.
41
-	 *
42
-	 * @var null|bool $lock
43
-	 */
44
-	public $lock = null;
45
-
46
-	/**
47
-	 * Holds the file handler resource if the file is opened.
48
-	 *
49
-	 * @var resource $handler
50
-	 */
51
-	protected $handler;
52
-
53
-	/**
54
-	 * The files size in bytes.
55
-	 *
56
-	 * @var float $size
57
-	 */
58
-	protected $size;
59
-
60
-	/**
61
-	 * Append given data string to this file.
62
-	 *
63
-	 * @param  string  $path
64
-	 * @param  string  $data
65
-	 * @param  bool  $force
66
-	 *
67
-	 * @return bool
68
-	 */
69
-	public function append($path, $data, $force = false)
70
-	{
71
-		return $this->write($path, $data, 'a', $force);
72
-	}
73
-
74
-	/**
75
-	 * Copy a file to a new location.
76
-	 *
77
-	 * @param  string  $path
78
-	 * @param  string  $target
79
-	 * 
80
-	 * @return bool
81
-	 */
82
-	public function copy($path, $target)
83
-	{
84
-		return copy($path, $target);
85
-	}
86
-
87
-	/**
88
-	 * Get the contents of a file.
89
-	 *
90
-	 * @param  string  $path
91
-	 * @param  bool  $lock  (false by default)
92
-	 * @param  bool  $force  (false by default)
93
-	 *
94
-	 * @return string
95
-	 *
96
-	 * @throws FileNotFoundException
97
-	 */
98
-	public function get($path, $lock = false, $force = false)
99
-	{
100
-		if ($this->isFile($path))
101
-		{
102
-			return $lock ? $this->read($path, $force) : file_get_contents($path);
103
-		}
104
-
105
-		throw new FileNotFoundException($path);
106
-	}
107
-
108
-	/**
109
-	 * Get contents of a file with shared access.
110
-	 *
111
-	 * @param  string  $path
112
-	 * @param  bool  $force  
113
-	 *
114
-	 * @return string
115
-	 */
116
-	protected function read($path, $force = false)
117
-	{
118
-		$contents = '';
119
-
120
-		$this->open($path, 'rb', $force);
39
+    /**
40
+     * Enable locking for file reading and writing.
41
+     *
42
+     * @var null|bool $lock
43
+     */
44
+    public $lock = null;
45
+
46
+    /**
47
+     * Holds the file handler resource if the file is opened.
48
+     *
49
+     * @var resource $handler
50
+     */
51
+    protected $handler;
52
+
53
+    /**
54
+     * The files size in bytes.
55
+     *
56
+     * @var float $size
57
+     */
58
+    protected $size;
59
+
60
+    /**
61
+     * Append given data string to this file.
62
+     *
63
+     * @param  string  $path
64
+     * @param  string  $data
65
+     * @param  bool  $force
66
+     *
67
+     * @return bool
68
+     */
69
+    public function append($path, $data, $force = false)
70
+    {
71
+        return $this->write($path, $data, 'a', $force);
72
+    }
73
+
74
+    /**
75
+     * Copy a file to a new location.
76
+     *
77
+     * @param  string  $path
78
+     * @param  string  $target
79
+     * 
80
+     * @return bool
81
+     */
82
+    public function copy($path, $target)
83
+    {
84
+        return copy($path, $target);
85
+    }
86
+
87
+    /**
88
+     * Get the contents of a file.
89
+     *
90
+     * @param  string  $path
91
+     * @param  bool  $lock  (false by default)
92
+     * @param  bool  $force  (false by default)
93
+     *
94
+     * @return string
95
+     *
96
+     * @throws FileNotFoundException
97
+     */
98
+    public function get($path, $lock = false, $force = false)
99
+    {
100
+        if ($this->isFile($path))
101
+        {
102
+            return $lock ? $this->read($path, $force) : file_get_contents($path);
103
+        }
104
+
105
+        throw new FileNotFoundException($path);
106
+    }
107
+
108
+    /**
109
+     * Get contents of a file with shared access.
110
+     *
111
+     * @param  string  $path
112
+     * @param  bool  $force  
113
+     *
114
+     * @return string
115
+     */
116
+    protected function read($path, $force = false)
117
+    {
118
+        $contents = '';
119
+
120
+        $this->open($path, 'rb', $force);
121 121
 		
122
-		if ($this->handler) 
123
-		{
124
-			try
125
-			{
126
-				if (flock($this->handler, LOCK_SH))
127
-				{
128
-					$this->clearStatCache($path);
129
-
130
-					$contents = fread($this->handler, $this->getSize($path) ?: 1);
122
+        if ($this->handler) 
123
+        {
124
+            try
125
+            {
126
+                if (flock($this->handler, LOCK_SH))
127
+                {
128
+                    $this->clearStatCache($path);
129
+
130
+                    $contents = fread($this->handler, $this->getSize($path) ?: 1);
131 131
 					
132
-					while ( ! feof($this->handler))
133
-					{
134
-						$contents .= fgets($this->handler, 4096);
135
-					}
136
-
137
-					flock($this->handler, LOCK_UN);
138
-				}
139
-			}
140
-			finally
141
-			{
142
-				$this->close();
143
-			}
144
-		}
145
-
146
-		return trim($contents);
147
-	}
148
-
149
-	/**
150
-	 * Opens the current file with a given $mode.
151
-	 *
152
-	 * @param  string  $path
153
-	 * @param  string  $mode  A valid 'fopen' mode string (r|w|a ...)
154
-	 * @param  bool  $force  
155
-	 *
156
-	 * @return bool
157
-	 */
158
-	public function open($path, $mode, $force = false)
159
-	{
160
-		if ( ! $force && is_resource($this->handler))
161
-		{
162
-			return true;
163
-		}
164
-
165
-		if ($this->exists($path) === false)
166
-		{
167
-			if ($this->create($path) === false)
168
-			{
169
-				return false;
170
-			}
171
-		}
172
-
173
-		$this->handler = fopen($path, $mode);
174
-
175
-		return is_resource($this->handler);
176
-	}
177
-
178
-	/**
179
-	 * Creates the file.
180
-	 * 
181
-	 * @param  string  $path
182
-	 * 
183
-	 * @return bool
184
-	 */
185
-	public function create($path)
186
-	{
187
-		if (($this->isDirectory($path)) && ($this->isWritable($path)) || ! $this->exists($path))
188
-		{
189
-			if (touch($path))
190
-			{
191
-				return true;
192
-			}
193
-		}
194
-
195
-		return false;
196
-	}
197
-
198
-	/**
199
-	 * Determine if a file exists.
200
-	 *
201
-	 * @param  string  $path
202
-	 *
203
-	 * @return bool
204
-	 */
205
-	public function exists($path)
206
-	{
207
-		$this->clearStatCache($path);
208
-
209
-		return file_exists($path);
210
-	}
211
-
212
-	/**
213
-	 * Clear PHP's internal stat cache.
214
-	 *
215
-	 * @param  string  $path
216
-	 * @param  bool  $all  Clear all cache or not
217
-	 *
218
-	 * @return void
219
-	 */
220
-	public function clearStatCache($path, $all = false)
221
-	{
222
-		if ($all === false) 
223
-		{
224
-			clearstatcache(true, $path);
225
-		}
226
-
227
-		clearstatcache();
228
-	}
229
-
230
-	/**
231
-	 * Get the returned value of a file.
232
-	 * 
233
-	 * @param  string  $path
234
-	 * @param  array  $data
235
-	 * 
236
-	 * @return mixed
237
-	 * 
238
-	 * @throws \Syscodes\Filesystem\Exceptions\FileNotFoundException
239
-	 */
240
-	public function getRequire($path, array $data = [])
241
-	{
242
-		if ($this->isFile($path)) {
243
-			$__path = $path;
244
-			$__data = $data;
245
-
246
-			return (static function () use ($__path, $__data) {
247
-				extract($__data, EXTR_SKIP);
248
-
249
-				return require $__path;
250
-			})();
251
-		}
252
-
253
-		throw new FileNotFoundException($path);
254
-	}
255
-
256
-	/**
257
-	 * Require the given file once.
258
-	 * 
259
-	 * @param  string  $path
260
-	 * @param  array  $data
261
-	 * 
262
-	 * @return mixed
263
-	 * 
264
-	 * @throws \Syscodes\Filesystem\Exceptions\FileNotFoundException
265
-	 */
266
-	public function getRequireOnce($path, array $data = [])
267
-	{
268
-		if ($this->isFile($path)) {
269
-			$__path = $path;
270
-			$__data = $data;
271
-
272
-			return (static function () use ($__path, $__data) {
273
-				extract($__data, EXTR_SKIP);
274
-
275
-				return require_once $__path;
276
-			})();
277
-		}
278
-
279
-		throw new FileNotFoundException($path);
280
-	}
281
-
282
-	/**
283
-	 * Retrieve the file size.
284
-	 *
285
-	 * Implementations SHOULD return the value stored in the "size" key of
286
-	 * the file in the $_FILES array if available, as PHP calculates this
287
-	 * based on the actual size transmitted.
288
-	 *
289
-	 * @param  string  $path
290
-	 * @param  string  $unit  ('b' by default)
291
-	 * 
292
-	 * @return int|null  The file size in bytes or null if unknown
293
-	 */
294
-	public function getSize($path, $unit = 'b')
295
-	{
296
-		if ($this->exists($path))
297
-		{
298
-			if (is_null($this->size))
299
-			{
300
-				$this->size = filesize($path);
301
-			}
302
-
303
-			switch (strtolower($unit))
304
-			{
305
-				case 'kb':
306
-					return number_format($this->size / 1024, 3);
307
-					break;
308
-				case 'mb':
309
-					return number_format(($this->size / 1024) / 1024, 3);     
310
-					break;
311
-			}
312
-
313
-			return $this->size;
314
-		}
315
-	}
132
+                    while ( ! feof($this->handler))
133
+                    {
134
+                        $contents .= fgets($this->handler, 4096);
135
+                    }
136
+
137
+                    flock($this->handler, LOCK_UN);
138
+                }
139
+            }
140
+            finally
141
+            {
142
+                $this->close();
143
+            }
144
+        }
145
+
146
+        return trim($contents);
147
+    }
148
+
149
+    /**
150
+     * Opens the current file with a given $mode.
151
+     *
152
+     * @param  string  $path
153
+     * @param  string  $mode  A valid 'fopen' mode string (r|w|a ...)
154
+     * @param  bool  $force  
155
+     *
156
+     * @return bool
157
+     */
158
+    public function open($path, $mode, $force = false)
159
+    {
160
+        if ( ! $force && is_resource($this->handler))
161
+        {
162
+            return true;
163
+        }
164
+
165
+        if ($this->exists($path) === false)
166
+        {
167
+            if ($this->create($path) === false)
168
+            {
169
+                return false;
170
+            }
171
+        }
172
+
173
+        $this->handler = fopen($path, $mode);
174
+
175
+        return is_resource($this->handler);
176
+    }
177
+
178
+    /**
179
+     * Creates the file.
180
+     * 
181
+     * @param  string  $path
182
+     * 
183
+     * @return bool
184
+     */
185
+    public function create($path)
186
+    {
187
+        if (($this->isDirectory($path)) && ($this->isWritable($path)) || ! $this->exists($path))
188
+        {
189
+            if (touch($path))
190
+            {
191
+                return true;
192
+            }
193
+        }
194
+
195
+        return false;
196
+    }
197
+
198
+    /**
199
+     * Determine if a file exists.
200
+     *
201
+     * @param  string  $path
202
+     *
203
+     * @return bool
204
+     */
205
+    public function exists($path)
206
+    {
207
+        $this->clearStatCache($path);
208
+
209
+        return file_exists($path);
210
+    }
211
+
212
+    /**
213
+     * Clear PHP's internal stat cache.
214
+     *
215
+     * @param  string  $path
216
+     * @param  bool  $all  Clear all cache or not
217
+     *
218
+     * @return void
219
+     */
220
+    public function clearStatCache($path, $all = false)
221
+    {
222
+        if ($all === false) 
223
+        {
224
+            clearstatcache(true, $path);
225
+        }
226
+
227
+        clearstatcache();
228
+    }
229
+
230
+    /**
231
+     * Get the returned value of a file.
232
+     * 
233
+     * @param  string  $path
234
+     * @param  array  $data
235
+     * 
236
+     * @return mixed
237
+     * 
238
+     * @throws \Syscodes\Filesystem\Exceptions\FileNotFoundException
239
+     */
240
+    public function getRequire($path, array $data = [])
241
+    {
242
+        if ($this->isFile($path)) {
243
+            $__path = $path;
244
+            $__data = $data;
245
+
246
+            return (static function () use ($__path, $__data) {
247
+                extract($__data, EXTR_SKIP);
248
+
249
+                return require $__path;
250
+            })();
251
+        }
252
+
253
+        throw new FileNotFoundException($path);
254
+    }
255
+
256
+    /**
257
+     * Require the given file once.
258
+     * 
259
+     * @param  string  $path
260
+     * @param  array  $data
261
+     * 
262
+     * @return mixed
263
+     * 
264
+     * @throws \Syscodes\Filesystem\Exceptions\FileNotFoundException
265
+     */
266
+    public function getRequireOnce($path, array $data = [])
267
+    {
268
+        if ($this->isFile($path)) {
269
+            $__path = $path;
270
+            $__data = $data;
271
+
272
+            return (static function () use ($__path, $__data) {
273
+                extract($__data, EXTR_SKIP);
274
+
275
+                return require_once $__path;
276
+            })();
277
+        }
278
+
279
+        throw new FileNotFoundException($path);
280
+    }
281
+
282
+    /**
283
+     * Retrieve the file size.
284
+     *
285
+     * Implementations SHOULD return the value stored in the "size" key of
286
+     * the file in the $_FILES array if available, as PHP calculates this
287
+     * based on the actual size transmitted.
288
+     *
289
+     * @param  string  $path
290
+     * @param  string  $unit  ('b' by default)
291
+     * 
292
+     * @return int|null  The file size in bytes or null if unknown
293
+     */
294
+    public function getSize($path, $unit = 'b')
295
+    {
296
+        if ($this->exists($path))
297
+        {
298
+            if (is_null($this->size))
299
+            {
300
+                $this->size = filesize($path);
301
+            }
302
+
303
+            switch (strtolower($unit))
304
+            {
305
+                case 'kb':
306
+                    return number_format($this->size / 1024, 3);
307
+                    break;
308
+                case 'mb':
309
+                    return number_format(($this->size / 1024) / 1024, 3);     
310
+                    break;
311
+            }
312
+
313
+            return $this->size;
314
+        }
315
+    }
316 316
 	
317
-	/**
318
-	 * Returns the file's group.
319
-	 *
320
-	 * @param  string  $path
321
-	 * 
322
-	 * @return int|bool  The file group, or false in case of an error
323
-	 */
324
-	public function group($path)
325
-	{
326
-		if ($this->exists($path))
327
-		{
328
-			return filegroup($path);
329
-		}
330
-
331
-		return false;
332
-	}
317
+    /**
318
+     * Returns the file's group.
319
+     *
320
+     * @param  string  $path
321
+     * 
322
+     * @return int|bool  The file group, or false in case of an error
323
+     */
324
+    public function group($path)
325
+    {
326
+        if ($this->exists($path))
327
+        {
328
+            return filegroup($path);
329
+        }
330
+
331
+        return false;
332
+    }
333 333
 	
334
-	/**
335
-	 * Returns true if the file is executable.
336
-	 *
337
-	 * @param  string  $path
338
-	 * 
339
-	 * @return bool  True if file is executable, false otherwise
340
-	 */
341
-	public function exec($path)
342
-	{
343
-		return is_executable($path);
344
-	}
345
-
346
-	/**
347
-	 * Determine if the given path is a directory.
348
-	 *
349
-	 * @param  string  $directory
350
-	 *
351
-	 * @return bool
352
-	 */
353
-	public function isDirectory($directory)
354
-	{
355
-		return is_dir($directory);
356
-	}
357
-
358
-	/**
359
-	 * Determine if the given path is a file.
360
-	 *
361
-	 * @param  string  $file
362
-	 *
363
-	 * @return bool
364
-	 */
365
-	public function isFile($file)
366
-	{
367
-		return is_file($file);
368
-	}
369
-
370
-	/**
371
-	 * Determine if the given path is writable.
372
-	 * 
373
-	 * @param  string  $path
374
-	 * 
375
-	 * @return bool
376
-	 */
377
-	public function isWritable($path)
378
-	{
379
-		return is_writable($path);
380
-	}
381
-
382
-	/**
383
-	 * Returns if true the file is readable.
384
-	 *
385
-	 * @param  string  $path
386
-	 * 
387
-	 * @return bool  True if file is readable, false otherwise
388
-	 */
389
-	public function isReadable($path)
390
-	{
391
-		return is_readable($path);
392
-	}
393
-
394
-	/**
395
-	 * Returns last access time.
396
-	 *
397
-	 * @param  string  $path
398
-	 * 
399
-	 * @return int|bool  Timestamp of last access time, or false in case of an error
400
-	 */
401
-	public function lastAccess($path)
402
-	{
403
-		if ($this->exists($path))
404
-		{
405
-			return fileatime($path);
406
-		}
407
-
408
-		return false;
409
-	}
410
-
411
-	/**
412
-	 * Returns last modified time.
413
-	 *
414
-	 * @param  string  $path
415
-	 * 
416
-	 * @return int|bool  Timestamp of last modified time, or false in case of an error
417
-	 */
418
-	public function lastModified($path)
419
-	{
420
-		if ($this->exists($path))
421
-		{
422
-			return filemtime($path);
423
-		}
424
-
425
-		return false;
426
-	}
427
-
428
-	/**
429
-	 * Get all of the directories within a given directory.
430
-	 * 
431
-	 * @param  string  $directory
432
-	 * 
433
-	 * @return array
434
-	 */
435
-	public function directories($directory)
436
-	{
437
-		$directories = [];
438
-
439
-		$iterators = new FilesystemIterator($directory);
440
-
441
-		foreach ($iterators as $iterator)
442
-		{
443
-			$directories[] = trim($iterator->getPathname(), '/').'/';
444
-		}
445
-
446
-		return $directories;
447
-	}
448
-
449
-	/**
450
-	 * Delete the file at a given path.
451
-	 * 
452
-	 * @param  string  $paths
453
-	 * 
454
-	 * @return bool
455
-	 */
456
-	public function delete($paths)
457
-	{
458
-		if (is_resource($this->handler))
459
-		{
460
-			fclose($this->handler);
461
-			$this->handler = null;
462
-		}
463
-
464
-		$paths = is_array($paths) ? $paths : func_get_args();
465
-
466
-		$success = true;
467
-
468
-		foreach ($paths as $path)
469
-		{
470
-			try
471
-			{
472
-				if ( ! @unlink($path))
473
-				{
474
-					return $success = false;
475
-				}
476
-			}
477
-			catch (ErrorException $e)
478
-			{
479
-				return $success = false;
480
-			}
481
-		}
482
-
483
-		return $success;
484
-	}
485
-
486
-	/**
487
-	 * Create a directory.
488
-	 *
489
-	 * @param  string  $path
490
-	 * @param  int  $mode
491
-	 * @param  bool  $recursive
492
-	 * @param  bool  $force
493
-	 *
494
-	 * @return bool
495
-	 * 
496
-	 * @throws FileException
497
-	 */
498
-	public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
499
-	{
500
-		if ($force)
501
-		{
502
-			return @mkdir($path, $mode, $recursive);
503
-		}
504
-
505
-		mkdir($path, $mode, $recursive);
506
-	}
507
-
508
-	/**
509
-	 * Copy a directory from one location to another.
510
-	 * 
511
-	 * @param  string  $directory
512
-	 * @param  string  $destination
513
-	 * @param  int  $options  (null by default)
514
-	 * 
515
-	 * @return bool
516
-	 */
517
-	public function copyDirectory($directory, $destination, $options = null)
518
-	{
519
-		if ( ! $this->isDirectory($directory)) return false;
520
-
521
-		$options = $options ?: FilesystemIterator::SKIP_DOTS;
334
+    /**
335
+     * Returns true if the file is executable.
336
+     *
337
+     * @param  string  $path
338
+     * 
339
+     * @return bool  True if file is executable, false otherwise
340
+     */
341
+    public function exec($path)
342
+    {
343
+        return is_executable($path);
344
+    }
345
+
346
+    /**
347
+     * Determine if the given path is a directory.
348
+     *
349
+     * @param  string  $directory
350
+     *
351
+     * @return bool
352
+     */
353
+    public function isDirectory($directory)
354
+    {
355
+        return is_dir($directory);
356
+    }
357
+
358
+    /**
359
+     * Determine if the given path is a file.
360
+     *
361
+     * @param  string  $file
362
+     *
363
+     * @return bool
364
+     */
365
+    public function isFile($file)
366
+    {
367
+        return is_file($file);
368
+    }
369
+
370
+    /**
371
+     * Determine if the given path is writable.
372
+     * 
373
+     * @param  string  $path
374
+     * 
375
+     * @return bool
376
+     */
377
+    public function isWritable($path)
378
+    {
379
+        return is_writable($path);
380
+    }
381
+
382
+    /**
383
+     * Returns if true the file is readable.
384
+     *
385
+     * @param  string  $path
386
+     * 
387
+     * @return bool  True if file is readable, false otherwise
388
+     */
389
+    public function isReadable($path)
390
+    {
391
+        return is_readable($path);
392
+    }
393
+
394
+    /**
395
+     * Returns last access time.
396
+     *
397
+     * @param  string  $path
398
+     * 
399
+     * @return int|bool  Timestamp of last access time, or false in case of an error
400
+     */
401
+    public function lastAccess($path)
402
+    {
403
+        if ($this->exists($path))
404
+        {
405
+            return fileatime($path);
406
+        }
407
+
408
+        return false;
409
+    }
410
+
411
+    /**
412
+     * Returns last modified time.
413
+     *
414
+     * @param  string  $path
415
+     * 
416
+     * @return int|bool  Timestamp of last modified time, or false in case of an error
417
+     */
418
+    public function lastModified($path)
419
+    {
420
+        if ($this->exists($path))
421
+        {
422
+            return filemtime($path);
423
+        }
424
+
425
+        return false;
426
+    }
427
+
428
+    /**
429
+     * Get all of the directories within a given directory.
430
+     * 
431
+     * @param  string  $directory
432
+     * 
433
+     * @return array
434
+     */
435
+    public function directories($directory)
436
+    {
437
+        $directories = [];
438
+
439
+        $iterators = new FilesystemIterator($directory);
440
+
441
+        foreach ($iterators as $iterator)
442
+        {
443
+            $directories[] = trim($iterator->getPathname(), '/').'/';
444
+        }
445
+
446
+        return $directories;
447
+    }
448
+
449
+    /**
450
+     * Delete the file at a given path.
451
+     * 
452
+     * @param  string  $paths
453
+     * 
454
+     * @return bool
455
+     */
456
+    public function delete($paths)
457
+    {
458
+        if (is_resource($this->handler))
459
+        {
460
+            fclose($this->handler);
461
+            $this->handler = null;
462
+        }
463
+
464
+        $paths = is_array($paths) ? $paths : func_get_args();
465
+
466
+        $success = true;
467
+
468
+        foreach ($paths as $path)
469
+        {
470
+            try
471
+            {
472
+                if ( ! @unlink($path))
473
+                {
474
+                    return $success = false;
475
+                }
476
+            }
477
+            catch (ErrorException $e)
478
+            {
479
+                return $success = false;
480
+            }
481
+        }
482
+
483
+        return $success;
484
+    }
485
+
486
+    /**
487
+     * Create a directory.
488
+     *
489
+     * @param  string  $path
490
+     * @param  int  $mode
491
+     * @param  bool  $recursive
492
+     * @param  bool  $force
493
+     *
494
+     * @return bool
495
+     * 
496
+     * @throws FileException
497
+     */
498
+    public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
499
+    {
500
+        if ($force)
501
+        {
502
+            return @mkdir($path, $mode, $recursive);
503
+        }
504
+
505
+        mkdir($path, $mode, $recursive);
506
+    }
507
+
508
+    /**
509
+     * Copy a directory from one location to another.
510
+     * 
511
+     * @param  string  $directory
512
+     * @param  string  $destination
513
+     * @param  int  $options  (null by default)
514
+     * 
515
+     * @return bool
516
+     */
517
+    public function copyDirectory($directory, $destination, $options = null)
518
+    {
519
+        if ( ! $this->isDirectory($directory)) return false;
520
+
521
+        $options = $options ?: FilesystemIterator::SKIP_DOTS;
522 522
 		
523
-		// If the destination directory does not actually exist, we will go ahead and
524
-		// create it recursively, which just gets the destination prepared to copy
525
-		// the files over. Once we make the directory we'll proceed the copying.
526
-		if ( ! $this->isdirectory($destination))
527
-		{
528
-			$this->makeDirectory($destination, 0777, true);
529
-		}
530
-
531
-		$iterators = new FilesystemIterator($directory, $options);
532
-
533
-		foreach ($iterators as $iterator)
534
-		{
535
-			$target = $destination.DIRECTORY_SEPARATOR.$iterator->getBasename();
523
+        // If the destination directory does not actually exist, we will go ahead and
524
+        // create it recursively, which just gets the destination prepared to copy
525
+        // the files over. Once we make the directory we'll proceed the copying.
526
+        if ( ! $this->isdirectory($destination))
527
+        {
528
+            $this->makeDirectory($destination, 0777, true);
529
+        }
530
+
531
+        $iterators = new FilesystemIterator($directory, $options);
532
+
533
+        foreach ($iterators as $iterator)
534
+        {
535
+            $target = $destination.DIRECTORY_SEPARATOR.$iterator->getBasename();
536 536
 			
537
-			// As we spin through items, we will check to see if the current file is actually
537
+            // As we spin through items, we will check to see if the current file is actually
538 538
             // a directory or a file. When it is actually a directory we will need to call
539 539
             // back into this function recursively to keep copying these nested folders.
540
-			if ($iterator->isDir())
541
-			{
542
-				if ( ! $this->copyDirectory($iterator->getPathname(), $target, $options)) return false;
543
-			}
544
-			// If the current items is just a regular file, we will just copy this to the new
545
-			// location and keep looping. If for some reason the copy fails we'll bail out
546
-			// and return false, so the developer is aware that the copy process failed.
547
-			else
548
-			{
549
-				if ( ! $this->copy($iterator->getPathname(), $target)) return false;
550
-			}
551
-		}
552
-
553
-		return true;
554
-	}
555
-
556
-	/**
557
-	 * Recursively delete a directory and optionally you can keep 
558
-	 * the directory if you wish.
559
-	 * 
560
-	 * @param  string  $directory
561
-	 * @param  bool  $keep
562
-	 * 
563
-	 * @return bool
564
-	 */
565
-	public function deleteDirectory($directory, $keep = false)
566
-	{
567
-		if ( ! $this->isDirectory($directory)) return false;
568
-
569
-		$iterators = new filesystemIterator($directory);
570
-
571
-		foreach ($iterators as $iterator)
572
-		{
573
-			// If the item is a directory, we can just recurse into the function and delete 
574
-			// that sub-directory otherwise we'll just delete the file and keep iterating 
575
-			// through each file until the directory is cleaned.
576
-			if ($iterator->isDir() && ! $iterator->isLink())
577
-			{
578
-				$this->deleteDirectory($iterator->getPathname());
579
-			}
580
-			// If the item is just a file, we can go ahead and delete it since we're
581
-			// just looping through and waxing all of the files in this directory
582
-			// and calling directories recursively, so we delete the real path.
583
-			else
584
-			{
585
-				$this->delete($iterator->getPathname());
586
-			}
587
-		}
588
-
589
-		if ( ! $keep) @rmdir($directory);
590
-
591
-		return true;
592
-	}
593
-
594
-	/**
595
-	 * Empty the specified directory of all files and folders.
596
-	 * 
597
-	 * 
598
-	 * @param  string  $directory
599
-	 * 
600
-	 * @return bool
601
-	 */
602
-	public function cleanDirectory($directory)
603
-	{
604
-		return $this->deleteDirectory($directory, true);
605
-	}
606
-
607
-	/**
608
-	 * Moves a file to a new location.
609
-	 * 
610
-	 * @param  string  $from
611
-	 * @param  string  $to
612
-	 * @param  bool  $overwrite  (false by default)
613
-	 * 
614
-	 * @return bool
615
-	 */
616
-	public function moveDirectory($from, $to, $overwrite = false)
617
-	{
618
-		if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) return false;
619
-
620
-		if (false === @rename($from, $to))
621
-		{
622
-			$error = error_get_last();
623
-
624
-			throw new FileUnableToMoveException($from, $to, strip_tags($error['message']));
625
-		}
626
-
627
-		$this->perms($to, 0777 & ~umask());
628
-	}
629
-
630
-	/**
631
-	 * Attempts to determine the file extension based on the trusted
632
-	 * getType() method. If the mime type is unknown, will return null.
633
-	 * 
634
-	 * @param  string  $path
635
-	 * 
636
-	 * @return string|null
637
-	 */
638
-	public function guessExtension($path)
639
-	{
640
-		return FileMimeType::guessExtensionFromType($this->getMimeType($path));
641
-	}
642
-
643
-	/**
644
-	 * Retrieve the media type of the file. 
645
-	 * 
646
-	 * @param  string  $path
647
-	 * 
648
-	 * @return string|null
649
-	 */
650
-	public function getMimeType($path)
651
-	{
652
-		$finfo    = finfo_open(FILEINFO_MIME_TYPE);
653
-		$mimeType = finfo_file($finfo, $path);
654
-
655
-		finfo_close($finfo);
656
-
657
-		return $mimeType;
658
-	}
659
-
660
-	/**
661
-	 * Move a file to a new location.
662
-	 *
663
-	 * @param  string  $path
664
-	 * @param  string  $target
665
-	 *
666
-	 * @return bool
667
-	 */
668
-	public function move($path, $target)
669
-	{
670
-		if ($this->exists($path)) 
671
-		{
672
-			return rename($path, $target);
673
-		}
674
-	}
675
-
676
-	/**
677
-	 * Extract the file name from a file path.
678
-	 * 
679
-	 * @param  string  $path
680
-	 * 
681
-	 * @return string
682
-	 */
683
-	public function name($path)
684
-	{
685
-		return pathinfo($path, PATHINFO_FILENAME);
686
-	}
687
-
688
-	/**
689
-	 * Extract the trailing name component from a file path.
690
-	 * 
691
-	 * @param  string  $path
692
-	 * 
693
-	 * @return string
694
-	 */
695
-	public function basename($path)
696
-	{
697
-		return pathinfo($path, PATHINFO_BASENAME);
698
-	}
699
-
700
-	/**
701
-	 * Extract the parent directory from a file path.
702
-	 * 
703
-	 * @param  string  $path
704
-	 * 
705
-	 * @return string
706
-	 */
707
-	public function dirname($path)
708
-	{
709
-		return pathinfo($path, PATHINFO_DIRNAME);
710
-	}
711
-
712
-	/**
713
-	 * Extract the file extension from a file path.
714
-	 * 
715
-	 * @param  string  $path
716
-	 * 
717
-	 * @return string
718
-	 */
719
-	public function extension($path)
720
-	{
721
-		return pathinfo($path, PATHINFO_EXTENSION);
722
-	}
723
-
724
-	/**
725
-	 *  Find path names matching a given pattern.
726
-	 * 
727
-	 * @param  string  $pattern
728
-	 * @param  int  $flags  (0 by default)
729
-	 * 
730
-	 * @return array
731
-	 */
732
-	public function glob($pattern, $flags = 0)
733
-	{
734
-		return glob($pattern, $flags);
735
-	}
736
-
737
-	/**
738
-	 * Returns the file's owner.
739
-	 *
740
-	 * @param  string  $path
741
-	 * 
742
-	 * @return int|bool  The file owner, or false in case of an error
743
-	 */
744
-	public function owner($path)
745
-	{
746
-		if ($this->exists($path))
747
-		{
748
-			return fileowner($path);
749
-		}
750
-
751
-		return false;
752
-	}
753
-
754
-	/**
755
-	 * Returns the "chmod" (permissions) of the file.
756
-	 *
757
-	 * @param  string  $path
758
-	 * @param  int|null  $mode  (null by default)
759
-	 * 
760
-	 * @return mixed  Permissions for the file, or false in case of an error
761
-	 */
762
-	public function perms($path, $mode = null)
763
-	{
764
-		if ($mode)
765
-		{
766
-			chmod($path, $mode);
767
-		}
768
-
769
-		return substr(sprintf('%o', fileperms($path)), -4);
770
-	}
771
-
772
-	/**
773
-	 * Prepend to a file.
774
-	 * 
775
-	 * @param  string  $path
776
-	 * @param  string  $data
777
-	 * 
778
-	 * @return int
779
-	 */
780
-	public function prepend($path, $data)
781
-	{
782
-		if ($this->exists($path))
783
-		{
784
-			$this->put($path, $data.$this->get($path));
785
-		}
786
-
787
-		return $this->put($path, $data);
788
-	}
789
-
790
-	/**
791
-	 * Write the content of a file.
792
-	 *
793
-	 * @param  string  $path
794
-	 * @param  string  $contents
795
-	 * @param  bool  $lock  (false by default)
796
-	 *
797
-	 * @return int
798
-	 */
799
-	public function put($path, $contents, $lock = false)
800
-	{
801
-		return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
802
-	}
803
-
804
-	/**
805
-	 * Get the file type of a given file.
806
-	 * 
807
-	 * @param  string  $path
808
-	 * 
809
-	 * @return string
810
-	 */
811
-	public function type($path)
812
-	{
813
-		return filetype($path);
814
-	}
815
-
816
-	/**
817
-	 * Searches for a given text and replaces the text if found.
818
-	 *
819
-	 * @param  string  $path
820
-	 * @param  string  $search
821
-	 * @param  string  $replace
822
-	 *
823
-	 * @return bool
824
-	 */
825
-	public function replaceText($path, $search, $replace)
826
-	{
827
-		if ( ! $this->open($path, 'r+'))
828
-		{
829
-			return false;
830
-		}
831
-
832
-		if ($this->lock !== null)
833
-		{
834
-			if (flock($this->handler, LOCK_EX) === false)
835
-			{
836
-				return false;
837
-			}
838
-		}
839
-
840
-		$replaced = $this->write($path, str_replace($search, $replace, $this->get($path)), true);
841
-
842
-		if ($this->lock !== null)
843
-		{
844
-			flock($this->handler, LOCK_UN);
845
-		}
846
-
847
-		$this->close();
848
-
849
-		return $replaced;
850
-	}	
851
-
852
-	/**
853
-	 * Closes the current file if it is opened.
854
-	 *
855
-	 * @return bool
856
-	 */
857
-	public function close()
858
-	{
859
-		if ( ! is_resource($this->handler))
860
-		{
861
-			return true;
862
-		}
863
-
864
-		return fclose($this->handler);
865
-	}
866
-
867
-	/**
868
-	 * Write given data to this file.
869
-	 *
870
-	 * @param  string  $path
871
-	 * @param  string  $data  Data to write to this File
872
-	 * @param  bool  $force  The file to open
873
-	 *
874
-	 * @return bool
875
-	 */
876
-	public function write($path, $data, $force = false)
877
-	{
878
-		$success = false;
879
-
880
-		if ($this->open($path, 'w', $force) === true)
881
-		{
882
-			if ($this->lock !== null)
883
-			{
884
-				if (flock($this->handler, LOCK_EX) === false)
885
-				{
886
-					return false;
887
-				}
888
-			}
889
-
890
-			if (fwrite($this->handler, $data) !== false)
891
-			{
892
-				$success = true;
893
-			}
894
-
895
-			if ($this->lock !== null)
896
-			{
897
-				flock($this->handler, LOCK_UN);
898
-			}
899
-		}
900
-
901
-		return $success;
902
-	}
540
+            if ($iterator->isDir())
541
+            {
542
+                if ( ! $this->copyDirectory($iterator->getPathname(), $target, $options)) return false;
543
+            }
544
+            // If the current items is just a regular file, we will just copy this to the new
545
+            // location and keep looping. If for some reason the copy fails we'll bail out
546
+            // and return false, so the developer is aware that the copy process failed.
547
+            else
548
+            {
549
+                if ( ! $this->copy($iterator->getPathname(), $target)) return false;
550
+            }
551
+        }
552
+
553
+        return true;
554
+    }
555
+
556
+    /**
557
+     * Recursively delete a directory and optionally you can keep 
558
+     * the directory if you wish.
559
+     * 
560
+     * @param  string  $directory
561
+     * @param  bool  $keep
562
+     * 
563
+     * @return bool
564
+     */
565
+    public function deleteDirectory($directory, $keep = false)
566
+    {
567
+        if ( ! $this->isDirectory($directory)) return false;
568
+
569
+        $iterators = new filesystemIterator($directory);
570
+
571
+        foreach ($iterators as $iterator)
572
+        {
573
+            // If the item is a directory, we can just recurse into the function and delete 
574
+            // that sub-directory otherwise we'll just delete the file and keep iterating 
575
+            // through each file until the directory is cleaned.
576
+            if ($iterator->isDir() && ! $iterator->isLink())
577
+            {
578
+                $this->deleteDirectory($iterator->getPathname());
579
+            }
580
+            // If the item is just a file, we can go ahead and delete it since we're
581
+            // just looping through and waxing all of the files in this directory
582
+            // and calling directories recursively, so we delete the real path.
583
+            else
584
+            {
585
+                $this->delete($iterator->getPathname());
586
+            }
587
+        }
588
+
589
+        if ( ! $keep) @rmdir($directory);
590
+
591
+        return true;
592
+    }
593
+
594
+    /**
595
+     * Empty the specified directory of all files and folders.
596
+     * 
597
+     * 
598
+     * @param  string  $directory
599
+     * 
600
+     * @return bool
601
+     */
602
+    public function cleanDirectory($directory)
603
+    {
604
+        return $this->deleteDirectory($directory, true);
605
+    }
606
+
607
+    /**
608
+     * Moves a file to a new location.
609
+     * 
610
+     * @param  string  $from
611
+     * @param  string  $to
612
+     * @param  bool  $overwrite  (false by default)
613
+     * 
614
+     * @return bool
615
+     */
616
+    public function moveDirectory($from, $to, $overwrite = false)
617
+    {
618
+        if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) return false;
619
+
620
+        if (false === @rename($from, $to))
621
+        {
622
+            $error = error_get_last();
623
+
624
+            throw new FileUnableToMoveException($from, $to, strip_tags($error['message']));
625
+        }
626
+
627
+        $this->perms($to, 0777 & ~umask());
628
+    }
629
+
630
+    /**
631
+     * Attempts to determine the file extension based on the trusted
632
+     * getType() method. If the mime type is unknown, will return null.
633
+     * 
634
+     * @param  string  $path
635
+     * 
636
+     * @return string|null
637
+     */
638
+    public function guessExtension($path)
639
+    {
640
+        return FileMimeType::guessExtensionFromType($this->getMimeType($path));
641
+    }
642
+
643
+    /**
644
+     * Retrieve the media type of the file. 
645
+     * 
646
+     * @param  string  $path
647
+     * 
648
+     * @return string|null
649
+     */
650
+    public function getMimeType($path)
651
+    {
652
+        $finfo    = finfo_open(FILEINFO_MIME_TYPE);
653
+        $mimeType = finfo_file($finfo, $path);
654
+
655
+        finfo_close($finfo);
656
+
657
+        return $mimeType;
658
+    }
659
+
660
+    /**
661
+     * Move a file to a new location.
662
+     *
663
+     * @param  string  $path
664
+     * @param  string  $target
665
+     *
666
+     * @return bool
667
+     */
668
+    public function move($path, $target)
669
+    {
670
+        if ($this->exists($path)) 
671
+        {
672
+            return rename($path, $target);
673
+        }
674
+    }
675
+
676
+    /**
677
+     * Extract the file name from a file path.
678
+     * 
679
+     * @param  string  $path
680
+     * 
681
+     * @return string
682
+     */
683
+    public function name($path)
684
+    {
685
+        return pathinfo($path, PATHINFO_FILENAME);
686
+    }
687
+
688
+    /**
689
+     * Extract the trailing name component from a file path.
690
+     * 
691
+     * @param  string  $path
692
+     * 
693
+     * @return string
694
+     */
695
+    public function basename($path)
696
+    {
697
+        return pathinfo($path, PATHINFO_BASENAME);
698
+    }
699
+
700
+    /**
701
+     * Extract the parent directory from a file path.
702
+     * 
703
+     * @param  string  $path
704
+     * 
705
+     * @return string
706
+     */
707
+    public function dirname($path)
708
+    {
709
+        return pathinfo($path, PATHINFO_DIRNAME);
710
+    }
711
+
712
+    /**
713
+     * Extract the file extension from a file path.
714
+     * 
715
+     * @param  string  $path
716
+     * 
717
+     * @return string
718
+     */
719
+    public function extension($path)
720
+    {
721
+        return pathinfo($path, PATHINFO_EXTENSION);
722
+    }
723
+
724
+    /**
725
+     *  Find path names matching a given pattern.
726
+     * 
727
+     * @param  string  $pattern
728
+     * @param  int  $flags  (0 by default)
729
+     * 
730
+     * @return array
731
+     */
732
+    public function glob($pattern, $flags = 0)
733
+    {
734
+        return glob($pattern, $flags);
735
+    }
736
+
737
+    /**
738
+     * Returns the file's owner.
739
+     *
740
+     * @param  string  $path
741
+     * 
742
+     * @return int|bool  The file owner, or false in case of an error
743
+     */
744
+    public function owner($path)
745
+    {
746
+        if ($this->exists($path))
747
+        {
748
+            return fileowner($path);
749
+        }
750
+
751
+        return false;
752
+    }
753
+
754
+    /**
755
+     * Returns the "chmod" (permissions) of the file.
756
+     *
757
+     * @param  string  $path
758
+     * @param  int|null  $mode  (null by default)
759
+     * 
760
+     * @return mixed  Permissions for the file, or false in case of an error
761
+     */
762
+    public function perms($path, $mode = null)
763
+    {
764
+        if ($mode)
765
+        {
766
+            chmod($path, $mode);
767
+        }
768
+
769
+        return substr(sprintf('%o', fileperms($path)), -4);
770
+    }
771
+
772
+    /**
773
+     * Prepend to a file.
774
+     * 
775
+     * @param  string  $path
776
+     * @param  string  $data
777
+     * 
778
+     * @return int
779
+     */
780
+    public function prepend($path, $data)
781
+    {
782
+        if ($this->exists($path))
783
+        {
784
+            $this->put($path, $data.$this->get($path));
785
+        }
786
+
787
+        return $this->put($path, $data);
788
+    }
789
+
790
+    /**
791
+     * Write the content of a file.
792
+     *
793
+     * @param  string  $path
794
+     * @param  string  $contents
795
+     * @param  bool  $lock  (false by default)
796
+     *
797
+     * @return int
798
+     */
799
+    public function put($path, $contents, $lock = false)
800
+    {
801
+        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
802
+    }
803
+
804
+    /**
805
+     * Get the file type of a given file.
806
+     * 
807
+     * @param  string  $path
808
+     * 
809
+     * @return string
810
+     */
811
+    public function type($path)
812
+    {
813
+        return filetype($path);
814
+    }
815
+
816
+    /**
817
+     * Searches for a given text and replaces the text if found.
818
+     *
819
+     * @param  string  $path
820
+     * @param  string  $search
821
+     * @param  string  $replace
822
+     *
823
+     * @return bool
824
+     */
825
+    public function replaceText($path, $search, $replace)
826
+    {
827
+        if ( ! $this->open($path, 'r+'))
828
+        {
829
+            return false;
830
+        }
831
+
832
+        if ($this->lock !== null)
833
+        {
834
+            if (flock($this->handler, LOCK_EX) === false)
835
+            {
836
+                return false;
837
+            }
838
+        }
839
+
840
+        $replaced = $this->write($path, str_replace($search, $replace, $this->get($path)), true);
841
+
842
+        if ($this->lock !== null)
843
+        {
844
+            flock($this->handler, LOCK_UN);
845
+        }
846
+
847
+        $this->close();
848
+
849
+        return $replaced;
850
+    }	
851
+
852
+    /**
853
+     * Closes the current file if it is opened.
854
+     *
855
+     * @return bool
856
+     */
857
+    public function close()
858
+    {
859
+        if ( ! is_resource($this->handler))
860
+        {
861
+            return true;
862
+        }
863
+
864
+        return fclose($this->handler);
865
+    }
866
+
867
+    /**
868
+     * Write given data to this file.
869
+     *
870
+     * @param  string  $path
871
+     * @param  string  $data  Data to write to this File
872
+     * @param  bool  $force  The file to open
873
+     *
874
+     * @return bool
875
+     */
876
+    public function write($path, $data, $force = false)
877
+    {
878
+        $success = false;
879
+
880
+        if ($this->open($path, 'w', $force) === true)
881
+        {
882
+            if ($this->lock !== null)
883
+            {
884
+                if (flock($this->handler, LOCK_EX) === false)
885
+                {
886
+                    return false;
887
+                }
888
+            }
889
+
890
+            if (fwrite($this->handler, $data) !== false)
891
+            {
892
+                $success = true;
893
+            }
894
+
895
+            if ($this->lock !== null)
896
+            {
897
+                flock($this->handler, LOCK_UN);
898
+            }
899
+        }
900
+
901
+        return $success;
902
+    }
903 903
 }
904 904
\ 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
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 			$__path = $path;
244 244
 			$__data = $data;
245 245
 
246
-			return (static function () use ($__path, $__data) {
246
+			return (static function() use ($__path, $__data) {
247 247
 				extract($__data, EXTR_SKIP);
248 248
 
249 249
 				return require $__path;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 			$__path = $path;
270 270
 			$__data = $data;
271 271
 
272
-			return (static function () use ($__path, $__data) {
272
+			return (static function() use ($__path, $__data) {
273 273
 				extract($__data, EXTR_SKIP);
274 274
 
275 275
 				return require_once $__path;
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -136,8 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 					flock($this->handler, LOCK_UN);
138 138
 				}
139
-			}
140
-			finally
139
+			} finally
141 140
 			{
142 141
 				$this->close();
143 142
 			}
@@ -473,8 +472,7 @@  discard block
 block discarded – undo
473 472
 				{
474 473
 					return $success = false;
475 474
 				}
476
-			}
477
-			catch (ErrorException $e)
475
+			} catch (ErrorException $e)
478 476
 			{
479 477
 				return $success = false;
480 478
 			}
@@ -516,7 +514,9 @@  discard block
 block discarded – undo
516 514
 	 */
517 515
 	public function copyDirectory($directory, $destination, $options = null)
518 516
 	{
519
-		if ( ! $this->isDirectory($directory)) return false;
517
+		if ( ! $this->isDirectory($directory)) {
518
+		    return false;
519
+		}
520 520
 
521 521
 		$options = $options ?: FilesystemIterator::SKIP_DOTS;
522 522
 		
@@ -539,14 +539,18 @@  discard block
 block discarded – undo
539 539
             // back into this function recursively to keep copying these nested folders.
540 540
 			if ($iterator->isDir())
541 541
 			{
542
-				if ( ! $this->copyDirectory($iterator->getPathname(), $target, $options)) return false;
542
+				if ( ! $this->copyDirectory($iterator->getPathname(), $target, $options)) {
543
+				    return false;
544
+				}
543 545
 			}
544 546
 			// If the current items is just a regular file, we will just copy this to the new
545 547
 			// location and keep looping. If for some reason the copy fails we'll bail out
546 548
 			// and return false, so the developer is aware that the copy process failed.
547 549
 			else
548 550
 			{
549
-				if ( ! $this->copy($iterator->getPathname(), $target)) return false;
551
+				if ( ! $this->copy($iterator->getPathname(), $target)) {
552
+				    return false;
553
+				}
550 554
 			}
551 555
 		}
552 556
 
@@ -564,7 +568,9 @@  discard block
 block discarded – undo
564 568
 	 */
565 569
 	public function deleteDirectory($directory, $keep = false)
566 570
 	{
567
-		if ( ! $this->isDirectory($directory)) return false;
571
+		if ( ! $this->isDirectory($directory)) {
572
+		    return false;
573
+		}
568 574
 
569 575
 		$iterators = new filesystemIterator($directory);
570 576
 
@@ -586,7 +592,9 @@  discard block
 block discarded – undo
586 592
 			}
587 593
 		}
588 594
 
589
-		if ( ! $keep) @rmdir($directory);
595
+		if ( ! $keep) {
596
+		    @rmdir($directory);
597
+		}
590 598
 
591 599
 		return true;
592 600
 	}
@@ -615,7 +623,9 @@  discard block
 block discarded – undo
615 623
 	 */
616 624
 	public function moveDirectory($from, $to, $overwrite = false)
617 625
 	{
618
-		if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) return false;
626
+		if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) {
627
+		    return false;
628
+		}
619 629
 
620 630
 		if (false === @rename($from, $to))
621 631
 		{
Please login to merge, or discard this patch.