Passed
Push — master ( fb679f...5d8234 )
by
unknown
01:37
created
src/Facades/OldInput.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  */
8 8
 class OldInput extends Facade
9 9
 {
10
-    protected static function getFacadeAccessor()
11
-    {
12
-        return 'framework.old_input.old_input';
13
-    }
10
+	protected static function getFacadeAccessor()
11
+	{
12
+		return 'framework.old_input.old_input';
13
+	}
14 14
 }
Please login to merge, or discard this patch.
src/Facades/Router.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  */
8 8
 class Router extends Facade
9 9
 {
10
-    protected static function getFacadeAccessor()
11
-    {
12
-        return 'framework.routing.router';
13
-    }
10
+	protected static function getFacadeAccessor()
11
+	{
12
+		return 'framework.routing.router';
13
+	}
14 14
 }
Please login to merge, or discard this patch.
src/Facades/Flash.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  */
8 8
 class Flash extends Facade
9 9
 {
10
-    protected static function getFacadeAccessor()
11
-    {
12
-        return 'framework.flash.flash';
13
-    }
10
+	protected static function getFacadeAccessor()
11
+	{
12
+		return 'framework.flash.flash';
13
+	}
14 14
 }
Please login to merge, or discard this patch.
src/Facades/Facade.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -12,216 +12,216 @@
 block discarded – undo
12 12
  */
13 13
 abstract class Facade
14 14
 {
15
-    /**
16
-     * The application instance being facaded.
17
-     *
18
-     * @var object
19
-     */
20
-    protected static $app;
21
-
22
-    /**
23
-     * The resolved object instances.
24
-     *
25
-     * @var array
26
-     */
27
-    protected static $resolvedInstance;
28
-
29
-    /**
30
-     * Convert the facade into a Mockery spy.
31
-     *
32
-     * @return void
33
-     */
34
-    public static function spy()
35
-    {
36
-        if (! static::isMock()) {
37
-            $class = static::getMockableClass();
38
-
39
-            static::swap($class ? Mockery::spy($class) : Mockery::spy());
40
-        }
41
-    }
42
-
43
-    /**
44
-     * Initiate a mock expectation on the facade.
45
-     *
46
-     * @return \Mockery\Expectation
47
-     */
48
-    public static function shouldReceive()
49
-    {
50
-        $name = static::getFacadeAccessor();
51
-
52
-        $mock = static::isMock()
53
-                    ? static::$resolvedInstance[$name]
54
-                    : static::createFreshMockInstance();
55
-
56
-        return $mock->shouldReceive(...func_get_args());
57
-    }
58
-
59
-    /**
60
-     * Create a fresh mock instance for the given class.
61
-     *
62
-     * @return \Mockery\Expectation
63
-     */
64
-    protected static function createFreshMockInstance()
65
-    {
66
-        return tap(static::createMock(), function ($mock) {
67
-            static::swap($mock);
68
-
69
-            $mock->shouldAllowMockingProtectedMethods();
70
-        });
71
-    }
72
-
73
-    /**
74
-     * Create a fresh mock instance for the given class.
75
-     *
76
-     * @return \Mockery\MockInterface
77
-     */
78
-    protected static function createMock()
79
-    {
80
-        $class = static::getMockableClass();
81
-
82
-        return $class ? Mockery::mock($class) : Mockery::mock();
83
-    }
84
-
85
-    /**
86
-     * Determines whether a mock is set as the instance of the facade.
87
-     *
88
-     * @return bool
89
-     */
90
-    protected static function isMock()
91
-    {
92
-        $name = static::getFacadeAccessor();
93
-
94
-        return isset(static::$resolvedInstance[$name]) &&
95
-               static::$resolvedInstance[$name] instanceof MockInterface;
96
-    }
97
-
98
-    /**
99
-     * Get the mockable class for the bound instance.
100
-     *
101
-     * @return string|null
102
-     */
103
-    protected static function getMockableClass()
104
-    {
105
-        if ($root = static::getFacadeRoot()) {
106
-            return get_class($root);
107
-        }
108
-    }
109
-
110
-    /**
111
-     * Hotswap the underlying instance behind the facade.
112
-     *
113
-     * @param  mixed  $instance
114
-     * @return void
115
-     */
116
-    public static function swap($instance)
117
-    {
118
-        static::$resolvedInstance[static::getFacadeAccessor()] = $instance;
119
-
120
-        if (isset(static::$app)) {
121
-            static::$app->instance(static::getFacadeAccessor(), $instance);
122
-        }
123
-    }
124
-
125
-    /**
126
-     * Get the root object behind the facade.
127
-     *
128
-     * @return mixed
129
-     */
130
-    public static function getFacadeRoot()
131
-    {
132
-        return static::resolveFacadeInstance(static::getFacadeAccessor());
133
-    }
134
-
135
-    /**
136
-     * Get the registered name of the component.
137
-     *
138
-     * @return string
139
-     *
140
-     * @throws \RuntimeException
141
-     */
142
-    protected static function getFacadeAccessor()
143
-    {
144
-        throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
145
-    }
146
-
147
-    /**
148
-     * Resolve the facade root instance from the container.
149
-     *
150
-     * @param  string|object  $name
151
-     * @return mixed
152
-     */
153
-    protected static function resolveFacadeInstance($name)
154
-    {
155
-        if (is_object($name)) {
156
-            return $name;
157
-        }
158
-
159
-        if (isset(static::$resolvedInstance[$name])) {
160
-            return static::$resolvedInstance[$name];
161
-        }
162
-
163
-        return static::$resolvedInstance[$name] = static::$app[$name];
164
-    }
165
-
166
-    /**
167
-     * Clear a resolved facade instance.
168
-     *
169
-     * @param  string  $name
170
-     * @return void
171
-     */
172
-    public static function clearResolvedInstance($name)
173
-    {
174
-        unset(static::$resolvedInstance[$name]);
175
-    }
176
-
177
-    /**
178
-     * Clear all of the resolved instances.
179
-     *
180
-     * @return void
181
-     */
182
-    public static function clearResolvedInstances()
183
-    {
184
-        static::$resolvedInstance = [];
185
-    }
186
-
187
-    /**
188
-     * Get the application instance behind the facade.
189
-     *
190
-     * @return object
191
-     */
192
-    public static function getFacadeApplication()
193
-    {
194
-        return static::$app;
195
-    }
196
-
197
-    /**
198
-     * Set the application instance.
199
-     *
200
-     * @param  object $app
201
-     * @return void
202
-     */
203
-    public static function setFacadeApplication($app)
204
-    {
205
-        static::$app = $app;
206
-    }
207
-
208
-    /**
209
-     * Handle dynamic, static calls to the object.
210
-     *
211
-     * @param  string  $method
212
-     * @param  array   $args
213
-     * @return mixed
214
-     *
215
-     * @throws \RuntimeException
216
-     */
217
-    public static function __callStatic($method, $args)
218
-    {
219
-        $instance = static::getFacadeRoot();
220
-
221
-        if (! $instance) {
222
-            throw new RuntimeException('A facade root has not been set.');
223
-        }
224
-
225
-        return $instance->$method(...$args);
226
-    }
15
+	/**
16
+	 * The application instance being facaded.
17
+	 *
18
+	 * @var object
19
+	 */
20
+	protected static $app;
21
+
22
+	/**
23
+	 * The resolved object instances.
24
+	 *
25
+	 * @var array
26
+	 */
27
+	protected static $resolvedInstance;
28
+
29
+	/**
30
+	 * Convert the facade into a Mockery spy.
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public static function spy()
35
+	{
36
+		if (! static::isMock()) {
37
+			$class = static::getMockableClass();
38
+
39
+			static::swap($class ? Mockery::spy($class) : Mockery::spy());
40
+		}
41
+	}
42
+
43
+	/**
44
+	 * Initiate a mock expectation on the facade.
45
+	 *
46
+	 * @return \Mockery\Expectation
47
+	 */
48
+	public static function shouldReceive()
49
+	{
50
+		$name = static::getFacadeAccessor();
51
+
52
+		$mock = static::isMock()
53
+					? static::$resolvedInstance[$name]
54
+					: static::createFreshMockInstance();
55
+
56
+		return $mock->shouldReceive(...func_get_args());
57
+	}
58
+
59
+	/**
60
+	 * Create a fresh mock instance for the given class.
61
+	 *
62
+	 * @return \Mockery\Expectation
63
+	 */
64
+	protected static function createFreshMockInstance()
65
+	{
66
+		return tap(static::createMock(), function ($mock) {
67
+			static::swap($mock);
68
+
69
+			$mock->shouldAllowMockingProtectedMethods();
70
+		});
71
+	}
72
+
73
+	/**
74
+	 * Create a fresh mock instance for the given class.
75
+	 *
76
+	 * @return \Mockery\MockInterface
77
+	 */
78
+	protected static function createMock()
79
+	{
80
+		$class = static::getMockableClass();
81
+
82
+		return $class ? Mockery::mock($class) : Mockery::mock();
83
+	}
84
+
85
+	/**
86
+	 * Determines whether a mock is set as the instance of the facade.
87
+	 *
88
+	 * @return bool
89
+	 */
90
+	protected static function isMock()
91
+	{
92
+		$name = static::getFacadeAccessor();
93
+
94
+		return isset(static::$resolvedInstance[$name]) &&
95
+			   static::$resolvedInstance[$name] instanceof MockInterface;
96
+	}
97
+
98
+	/**
99
+	 * Get the mockable class for the bound instance.
100
+	 *
101
+	 * @return string|null
102
+	 */
103
+	protected static function getMockableClass()
104
+	{
105
+		if ($root = static::getFacadeRoot()) {
106
+			return get_class($root);
107
+		}
108
+	}
109
+
110
+	/**
111
+	 * Hotswap the underlying instance behind the facade.
112
+	 *
113
+	 * @param  mixed  $instance
114
+	 * @return void
115
+	 */
116
+	public static function swap($instance)
117
+	{
118
+		static::$resolvedInstance[static::getFacadeAccessor()] = $instance;
119
+
120
+		if (isset(static::$app)) {
121
+			static::$app->instance(static::getFacadeAccessor(), $instance);
122
+		}
123
+	}
124
+
125
+	/**
126
+	 * Get the root object behind the facade.
127
+	 *
128
+	 * @return mixed
129
+	 */
130
+	public static function getFacadeRoot()
131
+	{
132
+		return static::resolveFacadeInstance(static::getFacadeAccessor());
133
+	}
134
+
135
+	/**
136
+	 * Get the registered name of the component.
137
+	 *
138
+	 * @return string
139
+	 *
140
+	 * @throws \RuntimeException
141
+	 */
142
+	protected static function getFacadeAccessor()
143
+	{
144
+		throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
145
+	}
146
+
147
+	/**
148
+	 * Resolve the facade root instance from the container.
149
+	 *
150
+	 * @param  string|object  $name
151
+	 * @return mixed
152
+	 */
153
+	protected static function resolveFacadeInstance($name)
154
+	{
155
+		if (is_object($name)) {
156
+			return $name;
157
+		}
158
+
159
+		if (isset(static::$resolvedInstance[$name])) {
160
+			return static::$resolvedInstance[$name];
161
+		}
162
+
163
+		return static::$resolvedInstance[$name] = static::$app[$name];
164
+	}
165
+
166
+	/**
167
+	 * Clear a resolved facade instance.
168
+	 *
169
+	 * @param  string  $name
170
+	 * @return void
171
+	 */
172
+	public static function clearResolvedInstance($name)
173
+	{
174
+		unset(static::$resolvedInstance[$name]);
175
+	}
176
+
177
+	/**
178
+	 * Clear all of the resolved instances.
179
+	 *
180
+	 * @return void
181
+	 */
182
+	public static function clearResolvedInstances()
183
+	{
184
+		static::$resolvedInstance = [];
185
+	}
186
+
187
+	/**
188
+	 * Get the application instance behind the facade.
189
+	 *
190
+	 * @return object
191
+	 */
192
+	public static function getFacadeApplication()
193
+	{
194
+		return static::$app;
195
+	}
196
+
197
+	/**
198
+	 * Set the application instance.
199
+	 *
200
+	 * @param  object $app
201
+	 * @return void
202
+	 */
203
+	public static function setFacadeApplication($app)
204
+	{
205
+		static::$app = $app;
206
+	}
207
+
208
+	/**
209
+	 * Handle dynamic, static calls to the object.
210
+	 *
211
+	 * @param  string  $method
212
+	 * @param  array   $args
213
+	 * @return mixed
214
+	 *
215
+	 * @throws \RuntimeException
216
+	 */
217
+	public static function __callStatic($method, $args)
218
+	{
219
+		$instance = static::getFacadeRoot();
220
+
221
+		if (! $instance) {
222
+			throw new RuntimeException('A facade root has not been set.');
223
+		}
224
+
225
+		return $instance->$method(...$args);
226
+	}
227 227
 }
Please login to merge, or discard this patch.
src/Support/AliasLoader.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -9,165 +9,165 @@
 block discarded – undo
9 9
  */
10 10
 class AliasLoader
11 11
 {
12
-    /**
13
-     * The array of class aliases.
14
-     *
15
-     * @var array
16
-     */
17
-    protected $aliases;
18
-
19
-    /**
20
-     * Indicates if a loader has been registered.
21
-     *
22
-     * @var bool
23
-     */
24
-    protected $registered = false;
25
-
26
-    /**
27
-     * The singleton instance of the loader.
28
-     *
29
-     * @var \CarbonFramework\Support\AliasLoader
30
-     */
31
-    protected static $instance;
32
-
33
-    /**
34
-     * Create a new AliasLoader instance.
35
-     *
36
-     * @param  array  $aliases
37
-     */
38
-    private function __construct($aliases)
39
-    {
40
-        $this->aliases = $aliases;
41
-    }
42
-
43
-    /**
44
-     * Get or create the singleton alias loader instance.
45
-     *
46
-     * @param  array  $aliases
47
-     * @return \CarbonFramework\Support\AliasLoader
48
-     */
49
-    public static function getInstance(array $aliases = [])
50
-    {
51
-        if (is_null(static::$instance)) {
52
-            return static::$instance = new static($aliases);
53
-        }
54
-
55
-        $aliases = array_merge(static::$instance->getAliases(), $aliases);
56
-
57
-        static::$instance->setAliases($aliases);
58
-
59
-        return static::$instance;
60
-    }
61
-
62
-    /**
63
-     * Load a class alias if it is registered.
64
-     *
65
-     * @param  string  $alias
66
-     * @return bool|null
67
-     */
68
-    public function load($alias)
69
-    {
70
-        if (isset($this->aliases[$alias])) {
71
-            return class_alias($this->aliases[$alias], $alias);
72
-        }
73
-    }
74
-
75
-    /**
76
-     * Add an alias to the loader.
77
-     *
78
-     * @param  string  $class
79
-     * @param  string  $alias
80
-     * @return void
81
-     */
82
-    public function alias($class, $alias)
83
-    {
84
-        $this->aliases[$class] = $alias;
85
-    }
86
-
87
-    /**
88
-     * Register the loader on the auto-loader stack.
89
-     *
90
-     * @return void
91
-     */
92
-    public function register()
93
-    {
94
-        if (! $this->registered) {
95
-            $this->prependToLoaderStack();
96
-
97
-            $this->registered = true;
98
-        }
99
-    }
100
-
101
-    /**
102
-     * Prepend the load method to the auto-loader stack.
103
-     *
104
-     * @return void
105
-     */
106
-    protected function prependToLoaderStack()
107
-    {
108
-        spl_autoload_register([$this, 'load'], true, true);
109
-    }
110
-
111
-    /**
112
-     * Get the registered aliases.
113
-     *
114
-     * @return array
115
-     */
116
-    public function getAliases()
117
-    {
118
-        return $this->aliases;
119
-    }
120
-
121
-    /**
122
-     * Set the registered aliases.
123
-     *
124
-     * @param  array  $aliases
125
-     * @return void
126
-     */
127
-    public function setAliases(array $aliases)
128
-    {
129
-        $this->aliases = $aliases;
130
-    }
131
-
132
-    /**
133
-     * Indicates if the loader has been registered.
134
-     *
135
-     * @return bool
136
-     */
137
-    public function isRegistered()
138
-    {
139
-        return $this->registered;
140
-    }
141
-
142
-    /**
143
-     * Set the "registered" state of the loader.
144
-     *
145
-     * @param  bool  $value
146
-     * @return void
147
-     */
148
-    public function setRegistered($value)
149
-    {
150
-        $this->registered = $value;
151
-    }
152
-
153
-    /**
154
-     * Set the value of the singleton alias loader.
155
-     *
156
-     * @param  \CarbonFramework\Support\AliasLoader $loader
157
-     * @return void
158
-     */
159
-    public static function setInstance($loader)
160
-    {
161
-        static::$instance = $loader;
162
-    }
163
-
164
-    /**
165
-     * Clone method.
166
-     *
167
-     * @return void
168
-     */
169
-    private function __clone()
170
-    {
171
-        //
172
-    }
12
+	/**
13
+	 * The array of class aliases.
14
+	 *
15
+	 * @var array
16
+	 */
17
+	protected $aliases;
18
+
19
+	/**
20
+	 * Indicates if a loader has been registered.
21
+	 *
22
+	 * @var bool
23
+	 */
24
+	protected $registered = false;
25
+
26
+	/**
27
+	 * The singleton instance of the loader.
28
+	 *
29
+	 * @var \CarbonFramework\Support\AliasLoader
30
+	 */
31
+	protected static $instance;
32
+
33
+	/**
34
+	 * Create a new AliasLoader instance.
35
+	 *
36
+	 * @param  array  $aliases
37
+	 */
38
+	private function __construct($aliases)
39
+	{
40
+		$this->aliases = $aliases;
41
+	}
42
+
43
+	/**
44
+	 * Get or create the singleton alias loader instance.
45
+	 *
46
+	 * @param  array  $aliases
47
+	 * @return \CarbonFramework\Support\AliasLoader
48
+	 */
49
+	public static function getInstance(array $aliases = [])
50
+	{
51
+		if (is_null(static::$instance)) {
52
+			return static::$instance = new static($aliases);
53
+		}
54
+
55
+		$aliases = array_merge(static::$instance->getAliases(), $aliases);
56
+
57
+		static::$instance->setAliases($aliases);
58
+
59
+		return static::$instance;
60
+	}
61
+
62
+	/**
63
+	 * Load a class alias if it is registered.
64
+	 *
65
+	 * @param  string  $alias
66
+	 * @return bool|null
67
+	 */
68
+	public function load($alias)
69
+	{
70
+		if (isset($this->aliases[$alias])) {
71
+			return class_alias($this->aliases[$alias], $alias);
72
+		}
73
+	}
74
+
75
+	/**
76
+	 * Add an alias to the loader.
77
+	 *
78
+	 * @param  string  $class
79
+	 * @param  string  $alias
80
+	 * @return void
81
+	 */
82
+	public function alias($class, $alias)
83
+	{
84
+		$this->aliases[$class] = $alias;
85
+	}
86
+
87
+	/**
88
+	 * Register the loader on the auto-loader stack.
89
+	 *
90
+	 * @return void
91
+	 */
92
+	public function register()
93
+	{
94
+		if (! $this->registered) {
95
+			$this->prependToLoaderStack();
96
+
97
+			$this->registered = true;
98
+		}
99
+	}
100
+
101
+	/**
102
+	 * Prepend the load method to the auto-loader stack.
103
+	 *
104
+	 * @return void
105
+	 */
106
+	protected function prependToLoaderStack()
107
+	{
108
+		spl_autoload_register([$this, 'load'], true, true);
109
+	}
110
+
111
+	/**
112
+	 * Get the registered aliases.
113
+	 *
114
+	 * @return array
115
+	 */
116
+	public function getAliases()
117
+	{
118
+		return $this->aliases;
119
+	}
120
+
121
+	/**
122
+	 * Set the registered aliases.
123
+	 *
124
+	 * @param  array  $aliases
125
+	 * @return void
126
+	 */
127
+	public function setAliases(array $aliases)
128
+	{
129
+		$this->aliases = $aliases;
130
+	}
131
+
132
+	/**
133
+	 * Indicates if the loader has been registered.
134
+	 *
135
+	 * @return bool
136
+	 */
137
+	public function isRegistered()
138
+	{
139
+		return $this->registered;
140
+	}
141
+
142
+	/**
143
+	 * Set the "registered" state of the loader.
144
+	 *
145
+	 * @param  bool  $value
146
+	 * @return void
147
+	 */
148
+	public function setRegistered($value)
149
+	{
150
+		$this->registered = $value;
151
+	}
152
+
153
+	/**
154
+	 * Set the value of the singleton alias loader.
155
+	 *
156
+	 * @param  \CarbonFramework\Support\AliasLoader $loader
157
+	 * @return void
158
+	 */
159
+	public static function setInstance($loader)
160
+	{
161
+		static::$instance = $loader;
162
+	}
163
+
164
+	/**
165
+	 * Clone method.
166
+	 *
167
+	 * @return void
168
+	 */
169
+	private function __clone()
170
+	{
171
+		//
172
+	}
173 173
 }
Please login to merge, or discard this patch.
src/Support/Arr.php 1 patch
Indentation   +489 added lines, -489 removed lines patch added patch discarded remove patch
@@ -10,493 +10,493 @@
 block discarded – undo
10 10
  */
11 11
 class Arr
12 12
 {
13
-    /**
14
-     * Determine whether the given value is array accessible.
15
-     *
16
-     * @param  mixed  $value
17
-     * @return bool
18
-     */
19
-    public static function accessible($value)
20
-    {
21
-        return is_array($value) || $value instanceof ArrayAccess;
22
-    }
23
-
24
-    /**
25
-     * Add an element to an array using "dot" notation if it doesn't exist.
26
-     *
27
-     * @param  array   $array
28
-     * @param  string  $key
29
-     * @param  mixed   $value
30
-     * @return array
31
-     */
32
-    public static function add($array, $key, $value)
33
-    {
34
-        if (is_null(static::get($array, $key))) {
35
-            static::set($array, $key, $value);
36
-        }
37
-
38
-        return $array;
39
-    }
40
-
41
-    /**
42
-     * Collapse an array of arrays into a single array.
43
-     *
44
-     * @param  array  $array
45
-     * @return array
46
-     */
47
-    public static function collapse($array)
48
-    {
49
-        $results = [];
50
-        foreach ($array as $values) {
51
-            if (! is_array($values)) {
52
-                continue;
53
-            }
54
-            $results = array_merge($results, $values);
55
-        }
56
-        return $results;
57
-    }
58
-
59
-    /**
60
-     * Divide an array into two arrays. One with keys and the other with values.
61
-     *
62
-     * @param  array  $array
63
-     * @return array
64
-     */
65
-    public static function divide($array)
66
-    {
67
-        return [array_keys($array), array_values($array)];
68
-    }
69
-
70
-    /**
71
-     * Flatten a multi-dimensional associative array with dots.
72
-     *
73
-     * @param  array   $array
74
-     * @param  string  $prepend
75
-     * @return array
76
-     */
77
-    public static function dot($array, $prepend = '')
78
-    {
79
-        $results = [];
80
-
81
-        foreach ($array as $key => $value) {
82
-            if (is_array($value) && ! empty($value)) {
83
-                $results = array_merge($results, static::dot($value, $prepend.$key.'.'));
84
-            } else {
85
-                $results[$prepend.$key] = $value;
86
-            }
87
-        }
88
-
89
-        return $results;
90
-    }
91
-
92
-    /**
93
-     * Get all of the given array except for a specified array of items.
94
-     *
95
-     * @param  array  $array
96
-     * @param  array|string  $keys
97
-     * @return array
98
-     */
99
-    public static function except($array, $keys)
100
-    {
101
-        static::forget($array, $keys);
102
-
103
-        return $array;
104
-    }
105
-
106
-    /**
107
-     * Determine if the given key exists in the provided array.
108
-     *
109
-     * @param  \ArrayAccess|array  $array
110
-     * @param  string|int  $key
111
-     * @return bool
112
-     */
113
-    public static function exists($array, $key)
114
-    {
115
-        if ($array instanceof ArrayAccess) {
116
-            return $array->offsetExists($key);
117
-        }
118
-
119
-        return array_key_exists($key, $array);
120
-    }
121
-
122
-    /**
123
-     * Return the first element in an array passing a given truth test.
124
-     *
125
-     * @param  array  $array
126
-     * @param  callable|null  $callback
127
-     * @param  mixed  $default
128
-     * @return mixed
129
-     */
130
-    public static function first($array, callable $callback = null, $default = null)
131
-    {
132
-        if (is_null($callback)) {
133
-            if (empty($array)) {
134
-                return $default;
135
-            }
136
-
137
-            foreach ($array as $item) {
138
-                return $item;
139
-            }
140
-        }
141
-
142
-        foreach ($array as $key => $value) {
143
-            if (call_user_func($callback, $value, $key)) {
144
-                return $value;
145
-            }
146
-        }
147
-
148
-        return $default;
149
-    }
150
-
151
-    /**
152
-     * Return the last element in an array passing a given truth test.
153
-     *
154
-     * @param  array  $array
155
-     * @param  callable|null  $callback
156
-     * @param  mixed  $default
157
-     * @return mixed
158
-     */
159
-    public static function last($array, callable $callback = null, $default = null)
160
-    {
161
-        if (is_null($callback)) {
162
-            return empty($array) ? $default : end($array);
163
-        }
164
-
165
-        return static::first(array_reverse($array, true), $callback, $default);
166
-    }
167
-
168
-    /**
169
-     * Remove one or many array items from a given array using "dot" notation.
170
-     *
171
-     * @param  array  $array
172
-     * @param  array|string  $keys
173
-     * @return void
174
-     */
175
-    public static function forget(&$array, $keys)
176
-    {
177
-        $original = &$array;
178
-
179
-        $keys = (array) $keys;
180
-
181
-        if (count($keys) === 0) {
182
-            return;
183
-        }
184
-
185
-        foreach ($keys as $key) {
186
-            // if the exact key exists in the top-level, remove it
187
-            if (static::exists($array, $key)) {
188
-                unset($array[$key]);
189
-
190
-                continue;
191
-            }
192
-
193
-            $parts = explode('.', $key);
194
-
195
-            // clean up before each pass
196
-            $array = &$original;
197
-
198
-            while (count($parts) > 1) {
199
-                $part = array_shift($parts);
200
-
201
-                if (isset($array[$part]) && is_array($array[$part])) {
202
-                    $array = &$array[$part];
203
-                } else {
204
-                    continue 2;
205
-                }
206
-            }
207
-
208
-            unset($array[array_shift($parts)]);
209
-        }
210
-    }
211
-
212
-    /**
213
-     * Get an item from an array using "dot" notation.
214
-     *
215
-     * @param  \ArrayAccess|array  $array
216
-     * @param  string  $key
217
-     * @param  mixed   $default
218
-     * @return mixed
219
-     */
220
-    public static function get($array, $key, $default = null)
221
-    {
222
-        if (! static::accessible($array)) {
223
-            return $default;
224
-        }
225
-
226
-        if (is_null($key)) {
227
-            return $array;
228
-        }
229
-
230
-        if (static::exists($array, $key)) {
231
-            return $array[$key];
232
-        }
233
-
234
-        foreach (explode('.', $key) as $segment) {
235
-            if (static::accessible($array) && static::exists($array, $segment)) {
236
-                $array = $array[$segment];
237
-            } else {
238
-                return $default;
239
-            }
240
-        }
241
-
242
-        return $array;
243
-    }
244
-
245
-    /**
246
-     * Check if an item or items exist in an array using "dot" notation.
247
-     *
248
-     * @param  \ArrayAccess|array  $array
249
-     * @param  string|array  $keys
250
-     * @return bool
251
-     */
252
-    public static function has($array, $keys)
253
-    {
254
-        if (is_null($keys)) {
255
-            return false;
256
-        }
257
-
258
-        $keys = (array) $keys;
259
-
260
-        if (! $array) {
261
-            return false;
262
-        }
263
-
264
-        if ($keys === []) {
265
-            return false;
266
-        }
267
-
268
-        foreach ($keys as $key) {
269
-            $subKeyArray = $array;
270
-
271
-            if (static::exists($array, $key)) {
272
-                continue;
273
-            }
274
-
275
-            foreach (explode('.', $key) as $segment) {
276
-                if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
277
-                    $subKeyArray = $subKeyArray[$segment];
278
-                } else {
279
-                    return false;
280
-                }
281
-            }
282
-        }
283
-
284
-        return true;
285
-    }
286
-
287
-    /**
288
-     * Determines if an array is associative.
289
-     *
290
-     * An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
291
-     *
292
-     * @param  array  $array
293
-     * @return bool
294
-     */
295
-    public static function isAssoc(array $array)
296
-    {
297
-        $keys = array_keys($array);
298
-
299
-        return array_keys($keys) !== $keys;
300
-    }
301
-
302
-    /**
303
-     * Get a subset of the items from the given array.
304
-     *
305
-     * @param  array  $array
306
-     * @param  array|string  $keys
307
-     * @return array
308
-     */
309
-    public static function only($array, $keys)
310
-    {
311
-        return array_intersect_key($array, array_flip((array) $keys));
312
-    }
313
-
314
-    /**
315
-     * Pluck an array of values from an array.
316
-     *
317
-     * @param  array  $array
318
-     * @param  string|array  $value
319
-     * @param  string|array|null  $key
320
-     * @return array
321
-     */
322
-    public static function pluck($array, $value, $key = null)
323
-    {
324
-        $results = [];
325
-
326
-        list($value, $key) = static::explodePluckParameters($value, $key);
327
-
328
-        foreach ($array as $item) {
329
-            $itemValue = static::data_get($item, $value);
330
-
331
-            // If the key is "null", we will just append the value to the array and keep
332
-            // looping. Otherwise we will key the array using the value of the key we
333
-            // received from the developer. Then we'll return the final array form.
334
-            if (is_null($key)) {
335
-                $results[] = $itemValue;
336
-            } else {
337
-                $itemKey = static::data_get($item, $key);
338
-
339
-                $results[$itemKey] = $itemValue;
340
-            }
341
-        }
342
-
343
-        return $results;
344
-    }
345
-
346
-    /**
347
-     * Explode the "value" and "key" arguments passed to "pluck".
348
-     *
349
-     * @param  string|array  $value
350
-     * @param  string|array|null  $key
351
-     * @return array
352
-     */
353
-    protected static function explodePluckParameters($value, $key)
354
-    {
355
-        $value = is_string($value) ? explode('.', $value) : $value;
356
-
357
-        $key = is_null($key) || is_array($key) ? $key : explode('.', $key);
358
-
359
-        return [$value, $key];
360
-    }
361
-
362
-    /**
363
-     * Push an item onto the beginning of an array.
364
-     *
365
-     * @param  array  $array
366
-     * @param  mixed  $value
367
-     * @param  mixed  $key
368
-     * @return array
369
-     */
370
-    public static function prepend($array, $value, $key = null)
371
-    {
372
-        if (is_null($key)) {
373
-            array_unshift($array, $value);
374
-        } else {
375
-            $array = [$key => $value] + $array;
376
-        }
377
-
378
-        return $array;
379
-    }
380
-
381
-    /**
382
-     * Get a value from the array, and remove it.
383
-     *
384
-     * @param  array   $array
385
-     * @param  string  $key
386
-     * @param  mixed   $default
387
-     * @return mixed
388
-     */
389
-    public static function pull(&$array, $key, $default = null)
390
-    {
391
-        $value = static::get($array, $key, $default);
392
-
393
-        static::forget($array, $key);
394
-
395
-        return $value;
396
-    }
397
-
398
-    /**
399
-     * Set an array item to a given value using "dot" notation.
400
-     *
401
-     * If no key is given to the method, the entire array will be replaced.
402
-     *
403
-     * @param  array   $array
404
-     * @param  string  $key
405
-     * @param  mixed   $value
406
-     * @return array
407
-     */
408
-    public static function set(&$array, $key, $value)
409
-    {
410
-        if (is_null($key)) {
411
-            return $array = $value;
412
-        }
413
-
414
-        $keys = explode('.', $key);
415
-
416
-        while (count($keys) > 1) {
417
-            $key = array_shift($keys);
418
-
419
-            // If the key doesn't exist at this depth, we will just create an empty array
420
-            // to hold the next value, allowing us to create the arrays to hold final
421
-            // values at the correct depth. Then we'll keep digging into the array.
422
-            if (! isset($array[$key]) || ! is_array($array[$key])) {
423
-                $array[$key] = [];
424
-            }
425
-
426
-            $array = &$array[$key];
427
-        }
428
-
429
-        $array[array_shift($keys)] = $value;
430
-
431
-        return $array;
432
-    }
433
-
434
-    /**
435
-     * Shuffle the given array and return the result.
436
-     *
437
-     * @param  array  $array
438
-     * @return array
439
-     */
440
-    public static function shuffle($array)
441
-    {
442
-        shuffle($array);
443
-
444
-        return $array;
445
-    }
446
-
447
-    /**
448
-     * Recursively sort an array by keys and values.
449
-     *
450
-     * @param  array  $array
451
-     * @return array
452
-     */
453
-    public static function sortRecursive($array)
454
-    {
455
-        foreach ($array as &$value) {
456
-            if (is_array($value)) {
457
-                $value = static::sortRecursive($value);
458
-            }
459
-        }
460
-
461
-        if (static::isAssoc($array)) {
462
-            ksort($array);
463
-        } else {
464
-            sort($array);
465
-        }
466
-
467
-        return $array;
468
-    }
469
-
470
-    /**
471
-     * Get an item from an array or object using "dot" notation.
472
-     *
473
-     * @param  mixed         $target
474
-     * @param  string|array  $key
475
-     * @param  mixed         $default
476
-     * @return mixed
477
-     */
478
-    public static function data_get($target, $key, $default = null)
479
-    {
480
-        if (is_null($key)) {
481
-            return $target;
482
-        }
483
-        $key = is_array($key) ? $key : explode('.', $key);
484
-        while (! is_null($segment = array_shift($key))) {
485
-            if ($segment === '*') {
486
-                if (! is_array($target)) {
487
-                    return $default;
488
-                }
489
-                $result = static::pluck($target, $key);
490
-                return in_array('*', $key) ? static::collapse($result) : $result;
491
-            }
492
-            if (static::accessible($target) && static::exists($target, $segment)) {
493
-                $target = $target[$segment];
494
-            } elseif (is_object($target) && isset($target->{$segment})) {
495
-                $target = $target->{$segment};
496
-            } else {
497
-                return $default;
498
-            }
499
-        }
500
-        return $target;
501
-    }
13
+	/**
14
+	 * Determine whether the given value is array accessible.
15
+	 *
16
+	 * @param  mixed  $value
17
+	 * @return bool
18
+	 */
19
+	public static function accessible($value)
20
+	{
21
+		return is_array($value) || $value instanceof ArrayAccess;
22
+	}
23
+
24
+	/**
25
+	 * Add an element to an array using "dot" notation if it doesn't exist.
26
+	 *
27
+	 * @param  array   $array
28
+	 * @param  string  $key
29
+	 * @param  mixed   $value
30
+	 * @return array
31
+	 */
32
+	public static function add($array, $key, $value)
33
+	{
34
+		if (is_null(static::get($array, $key))) {
35
+			static::set($array, $key, $value);
36
+		}
37
+
38
+		return $array;
39
+	}
40
+
41
+	/**
42
+	 * Collapse an array of arrays into a single array.
43
+	 *
44
+	 * @param  array  $array
45
+	 * @return array
46
+	 */
47
+	public static function collapse($array)
48
+	{
49
+		$results = [];
50
+		foreach ($array as $values) {
51
+			if (! is_array($values)) {
52
+				continue;
53
+			}
54
+			$results = array_merge($results, $values);
55
+		}
56
+		return $results;
57
+	}
58
+
59
+	/**
60
+	 * Divide an array into two arrays. One with keys and the other with values.
61
+	 *
62
+	 * @param  array  $array
63
+	 * @return array
64
+	 */
65
+	public static function divide($array)
66
+	{
67
+		return [array_keys($array), array_values($array)];
68
+	}
69
+
70
+	/**
71
+	 * Flatten a multi-dimensional associative array with dots.
72
+	 *
73
+	 * @param  array   $array
74
+	 * @param  string  $prepend
75
+	 * @return array
76
+	 */
77
+	public static function dot($array, $prepend = '')
78
+	{
79
+		$results = [];
80
+
81
+		foreach ($array as $key => $value) {
82
+			if (is_array($value) && ! empty($value)) {
83
+				$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
84
+			} else {
85
+				$results[$prepend.$key] = $value;
86
+			}
87
+		}
88
+
89
+		return $results;
90
+	}
91
+
92
+	/**
93
+	 * Get all of the given array except for a specified array of items.
94
+	 *
95
+	 * @param  array  $array
96
+	 * @param  array|string  $keys
97
+	 * @return array
98
+	 */
99
+	public static function except($array, $keys)
100
+	{
101
+		static::forget($array, $keys);
102
+
103
+		return $array;
104
+	}
105
+
106
+	/**
107
+	 * Determine if the given key exists in the provided array.
108
+	 *
109
+	 * @param  \ArrayAccess|array  $array
110
+	 * @param  string|int  $key
111
+	 * @return bool
112
+	 */
113
+	public static function exists($array, $key)
114
+	{
115
+		if ($array instanceof ArrayAccess) {
116
+			return $array->offsetExists($key);
117
+		}
118
+
119
+		return array_key_exists($key, $array);
120
+	}
121
+
122
+	/**
123
+	 * Return the first element in an array passing a given truth test.
124
+	 *
125
+	 * @param  array  $array
126
+	 * @param  callable|null  $callback
127
+	 * @param  mixed  $default
128
+	 * @return mixed
129
+	 */
130
+	public static function first($array, callable $callback = null, $default = null)
131
+	{
132
+		if (is_null($callback)) {
133
+			if (empty($array)) {
134
+				return $default;
135
+			}
136
+
137
+			foreach ($array as $item) {
138
+				return $item;
139
+			}
140
+		}
141
+
142
+		foreach ($array as $key => $value) {
143
+			if (call_user_func($callback, $value, $key)) {
144
+				return $value;
145
+			}
146
+		}
147
+
148
+		return $default;
149
+	}
150
+
151
+	/**
152
+	 * Return the last element in an array passing a given truth test.
153
+	 *
154
+	 * @param  array  $array
155
+	 * @param  callable|null  $callback
156
+	 * @param  mixed  $default
157
+	 * @return mixed
158
+	 */
159
+	public static function last($array, callable $callback = null, $default = null)
160
+	{
161
+		if (is_null($callback)) {
162
+			return empty($array) ? $default : end($array);
163
+		}
164
+
165
+		return static::first(array_reverse($array, true), $callback, $default);
166
+	}
167
+
168
+	/**
169
+	 * Remove one or many array items from a given array using "dot" notation.
170
+	 *
171
+	 * @param  array  $array
172
+	 * @param  array|string  $keys
173
+	 * @return void
174
+	 */
175
+	public static function forget(&$array, $keys)
176
+	{
177
+		$original = &$array;
178
+
179
+		$keys = (array) $keys;
180
+
181
+		if (count($keys) === 0) {
182
+			return;
183
+		}
184
+
185
+		foreach ($keys as $key) {
186
+			// if the exact key exists in the top-level, remove it
187
+			if (static::exists($array, $key)) {
188
+				unset($array[$key]);
189
+
190
+				continue;
191
+			}
192
+
193
+			$parts = explode('.', $key);
194
+
195
+			// clean up before each pass
196
+			$array = &$original;
197
+
198
+			while (count($parts) > 1) {
199
+				$part = array_shift($parts);
200
+
201
+				if (isset($array[$part]) && is_array($array[$part])) {
202
+					$array = &$array[$part];
203
+				} else {
204
+					continue 2;
205
+				}
206
+			}
207
+
208
+			unset($array[array_shift($parts)]);
209
+		}
210
+	}
211
+
212
+	/**
213
+	 * Get an item from an array using "dot" notation.
214
+	 *
215
+	 * @param  \ArrayAccess|array  $array
216
+	 * @param  string  $key
217
+	 * @param  mixed   $default
218
+	 * @return mixed
219
+	 */
220
+	public static function get($array, $key, $default = null)
221
+	{
222
+		if (! static::accessible($array)) {
223
+			return $default;
224
+		}
225
+
226
+		if (is_null($key)) {
227
+			return $array;
228
+		}
229
+
230
+		if (static::exists($array, $key)) {
231
+			return $array[$key];
232
+		}
233
+
234
+		foreach (explode('.', $key) as $segment) {
235
+			if (static::accessible($array) && static::exists($array, $segment)) {
236
+				$array = $array[$segment];
237
+			} else {
238
+				return $default;
239
+			}
240
+		}
241
+
242
+		return $array;
243
+	}
244
+
245
+	/**
246
+	 * Check if an item or items exist in an array using "dot" notation.
247
+	 *
248
+	 * @param  \ArrayAccess|array  $array
249
+	 * @param  string|array  $keys
250
+	 * @return bool
251
+	 */
252
+	public static function has($array, $keys)
253
+	{
254
+		if (is_null($keys)) {
255
+			return false;
256
+		}
257
+
258
+		$keys = (array) $keys;
259
+
260
+		if (! $array) {
261
+			return false;
262
+		}
263
+
264
+		if ($keys === []) {
265
+			return false;
266
+		}
267
+
268
+		foreach ($keys as $key) {
269
+			$subKeyArray = $array;
270
+
271
+			if (static::exists($array, $key)) {
272
+				continue;
273
+			}
274
+
275
+			foreach (explode('.', $key) as $segment) {
276
+				if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
277
+					$subKeyArray = $subKeyArray[$segment];
278
+				} else {
279
+					return false;
280
+				}
281
+			}
282
+		}
283
+
284
+		return true;
285
+	}
286
+
287
+	/**
288
+	 * Determines if an array is associative.
289
+	 *
290
+	 * An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
291
+	 *
292
+	 * @param  array  $array
293
+	 * @return bool
294
+	 */
295
+	public static function isAssoc(array $array)
296
+	{
297
+		$keys = array_keys($array);
298
+
299
+		return array_keys($keys) !== $keys;
300
+	}
301
+
302
+	/**
303
+	 * Get a subset of the items from the given array.
304
+	 *
305
+	 * @param  array  $array
306
+	 * @param  array|string  $keys
307
+	 * @return array
308
+	 */
309
+	public static function only($array, $keys)
310
+	{
311
+		return array_intersect_key($array, array_flip((array) $keys));
312
+	}
313
+
314
+	/**
315
+	 * Pluck an array of values from an array.
316
+	 *
317
+	 * @param  array  $array
318
+	 * @param  string|array  $value
319
+	 * @param  string|array|null  $key
320
+	 * @return array
321
+	 */
322
+	public static function pluck($array, $value, $key = null)
323
+	{
324
+		$results = [];
325
+
326
+		list($value, $key) = static::explodePluckParameters($value, $key);
327
+
328
+		foreach ($array as $item) {
329
+			$itemValue = static::data_get($item, $value);
330
+
331
+			// If the key is "null", we will just append the value to the array and keep
332
+			// looping. Otherwise we will key the array using the value of the key we
333
+			// received from the developer. Then we'll return the final array form.
334
+			if (is_null($key)) {
335
+				$results[] = $itemValue;
336
+			} else {
337
+				$itemKey = static::data_get($item, $key);
338
+
339
+				$results[$itemKey] = $itemValue;
340
+			}
341
+		}
342
+
343
+		return $results;
344
+	}
345
+
346
+	/**
347
+	 * Explode the "value" and "key" arguments passed to "pluck".
348
+	 *
349
+	 * @param  string|array  $value
350
+	 * @param  string|array|null  $key
351
+	 * @return array
352
+	 */
353
+	protected static function explodePluckParameters($value, $key)
354
+	{
355
+		$value = is_string($value) ? explode('.', $value) : $value;
356
+
357
+		$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
358
+
359
+		return [$value, $key];
360
+	}
361
+
362
+	/**
363
+	 * Push an item onto the beginning of an array.
364
+	 *
365
+	 * @param  array  $array
366
+	 * @param  mixed  $value
367
+	 * @param  mixed  $key
368
+	 * @return array
369
+	 */
370
+	public static function prepend($array, $value, $key = null)
371
+	{
372
+		if (is_null($key)) {
373
+			array_unshift($array, $value);
374
+		} else {
375
+			$array = [$key => $value] + $array;
376
+		}
377
+
378
+		return $array;
379
+	}
380
+
381
+	/**
382
+	 * Get a value from the array, and remove it.
383
+	 *
384
+	 * @param  array   $array
385
+	 * @param  string  $key
386
+	 * @param  mixed   $default
387
+	 * @return mixed
388
+	 */
389
+	public static function pull(&$array, $key, $default = null)
390
+	{
391
+		$value = static::get($array, $key, $default);
392
+
393
+		static::forget($array, $key);
394
+
395
+		return $value;
396
+	}
397
+
398
+	/**
399
+	 * Set an array item to a given value using "dot" notation.
400
+	 *
401
+	 * If no key is given to the method, the entire array will be replaced.
402
+	 *
403
+	 * @param  array   $array
404
+	 * @param  string  $key
405
+	 * @param  mixed   $value
406
+	 * @return array
407
+	 */
408
+	public static function set(&$array, $key, $value)
409
+	{
410
+		if (is_null($key)) {
411
+			return $array = $value;
412
+		}
413
+
414
+		$keys = explode('.', $key);
415
+
416
+		while (count($keys) > 1) {
417
+			$key = array_shift($keys);
418
+
419
+			// If the key doesn't exist at this depth, we will just create an empty array
420
+			// to hold the next value, allowing us to create the arrays to hold final
421
+			// values at the correct depth. Then we'll keep digging into the array.
422
+			if (! isset($array[$key]) || ! is_array($array[$key])) {
423
+				$array[$key] = [];
424
+			}
425
+
426
+			$array = &$array[$key];
427
+		}
428
+
429
+		$array[array_shift($keys)] = $value;
430
+
431
+		return $array;
432
+	}
433
+
434
+	/**
435
+	 * Shuffle the given array and return the result.
436
+	 *
437
+	 * @param  array  $array
438
+	 * @return array
439
+	 */
440
+	public static function shuffle($array)
441
+	{
442
+		shuffle($array);
443
+
444
+		return $array;
445
+	}
446
+
447
+	/**
448
+	 * Recursively sort an array by keys and values.
449
+	 *
450
+	 * @param  array  $array
451
+	 * @return array
452
+	 */
453
+	public static function sortRecursive($array)
454
+	{
455
+		foreach ($array as &$value) {
456
+			if (is_array($value)) {
457
+				$value = static::sortRecursive($value);
458
+			}
459
+		}
460
+
461
+		if (static::isAssoc($array)) {
462
+			ksort($array);
463
+		} else {
464
+			sort($array);
465
+		}
466
+
467
+		return $array;
468
+	}
469
+
470
+	/**
471
+	 * Get an item from an array or object using "dot" notation.
472
+	 *
473
+	 * @param  mixed         $target
474
+	 * @param  string|array  $key
475
+	 * @param  mixed         $default
476
+	 * @return mixed
477
+	 */
478
+	public static function data_get($target, $key, $default = null)
479
+	{
480
+		if (is_null($key)) {
481
+			return $target;
482
+		}
483
+		$key = is_array($key) ? $key : explode('.', $key);
484
+		while (! is_null($segment = array_shift($key))) {
485
+			if ($segment === '*') {
486
+				if (! is_array($target)) {
487
+					return $default;
488
+				}
489
+				$result = static::pluck($target, $key);
490
+				return in_array('*', $key) ? static::collapse($result) : $result;
491
+			}
492
+			if (static::accessible($target) && static::exists($target, $segment)) {
493
+				$target = $target[$segment];
494
+			} elseif (is_object($target) && isset($target->{$segment})) {
495
+				$target = $target->{$segment};
496
+			} else {
497
+				return $default;
498
+			}
499
+		}
500
+		return $target;
501
+	}
502 502
 }
Please login to merge, or discard this patch.