Passed
Push — 0.7.0 ( d23ad8...f7e7ba )
by Alexander
02:48 queued 11s
created
src/components/Support/Chronos/Traits/Factory.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
         $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
59 59
         
60 60
         if ( ! empty($time)) {
61
-			if (is_string($time) && static::hasRelativeKeywords($time)) {
62
-				$dateTime = new DateTime('now', $this->timezone);
63
-				$dateTime->modify($time);
61
+            if (is_string($time) && static::hasRelativeKeywords($time)) {
62
+                $dateTime = new DateTime('now', $this->timezone);
63
+                $dateTime->modify($time);
64 64
 
65
-				$time = $dateTime->format('Y-m-d H:i:s');
66
-			}
65
+                $time = $dateTime->format('Y-m-d H:i:s');
66
+            }
67 67
         }
68 68
         
69 69
         return parent::__construct($time, $this->timezone);
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
      * @return \Syscodes\Support\Chronos\Time
119 119
      */
120 120
     public static function yesterday($timezone = null, string $locale = null)
121
-	{
122
-		return static::parse(date('Y-m-d 00:00:00', strtotime('-1 day')), $timezone, $locale);
121
+    {
122
+        return static::parse(date('Y-m-d 00:00:00', strtotime('-1 day')), $timezone, $locale);
123 123
     }
124 124
 
125 125
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      * @return \Syscodes\Support\Chronos\Time
132 132
      */
133 133
     public static function tomorrow($timezone = null, string $locale = null)
134
-	{
135
-		return static::parse(date('Y-m-d 00:00:00', strtotime('+1 day')), $timezone, $locale);
134
+    {
135
+        return static::parse(date('Y-m-d 00:00:00', strtotime('+1 day')), $timezone, $locale);
136 136
     }
137 137
 
138 138
     /**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
     /**
266 266
      * Creates an instance of Time that will be returned during testing
267
-	 * when calling 'Time::now' instead of the current time.
267
+     * when calling 'Time::now' instead of the current time.
268 268
      * 
269 269
      * @param  \Syscodes\Support\Chronos\Time|string  $datetime  (null by default)
270 270
      * @param  string|null  $timezone (null by default)
Please login to merge, or discard this patch.
src/components/Support/Chronos/Traits/Schedule.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@
 block discarded – undo
164 164
 
165 165
         foreach ($transitions as $transition) {
166 166
             if ($transition['time'] > $this->format('U')) {
167
-               $dayLightSaving = (bool) $transition['isdst'] ?? $dayLightSaving;
167
+                $dayLightSaving = (bool) $transition['isdst'] ?? $dayLightSaving;
168 168
             }
169 169
         }
170 170
 
Please login to merge, or discard this patch.
src/components/Support/Finder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@
 block discarded – undo
167 167
 
168 168
         if ( ! empty($file) || ! is_null($file)) {
169 169
             $file = str_replace(['::', '.'], DIRECTORY_SEPARATOR, $file);
170
-        } else  {
170
+        } else {
171 171
             $file = $file ?: 'empty';
172 172
 
173 173
             throw new InvalidArgumentException("File not found: [{$file}]");
Please login to merge, or discard this patch.
src/components/Routing/UrlGenerator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
         $uri = $this->trimUrl($root, $this->replaceRouteParameters($route->getRoute(), $parameters));
264 264
 
265
-        return $forced ? $uri : '/' .ltrim(str_replace($root, '', $uri), '/');
265
+        return $forced ? $uri : '/'.ltrim(str_replace($root, '', $uri), '/');
266 266
     }
267 267
     
268 268
     /**
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     protected function replaceNamedParameters($path, &$parameters)
326 326
     {
327
-        return preg_replace_callback('/\{(.*?)\??\}/', function ($match) use (&$parameters) {
327
+        return preg_replace_callback('/\{(.*?)\??\}/', function($match) use (&$parameters) {
328 328
             return isset($parameters[$match[1]]) ? Arr::pull($parameters, $match[1]) : $match[0];
329 329
         }, $path);
330 330
     }
Please login to merge, or discard this patch.
src/components/Routing/ResourceRegister.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -339,7 +339,7 @@
 block discarded – undo
339 339
      */
340 340
     protected function getNestedResourceUri(array $segments)
341 341
     {
342
-        return implode('/', array_map(function ($segment) {
342
+        return implode('/', array_map(function($segment) {
343 343
             return $segment.'/{'.$this->getResourceWilcard($segment).'}';
344 344
         }, $segments));
345 345
     }
Please login to merge, or discard this patch.
src/components/Routing/Router.php 2 patches
Indentation   +557 added lines, -557 removed lines patch added patch discarded remove patch
@@ -39,581 +39,581 @@
 block discarded – undo
39 39
  */
40 40
 class Router implements Routable
41 41
 {
42
-	use Concerns\RouteMap,
43
-	    Concerns\RouteResolver;
44
-
45
-	/**
46
-	 * The registered route value binders.
47
-	 * 
48
-	 * @var array $binders
49
-	 */
50
-	protected $binders = [];
51
-
52
-	/**
53
-	 * The container instance used by the router.
54
-	 * 
55
-	 * @var \Syscodes\Contracts\Container\Container $container
56
-	 */
57
-	protected $container;
58
-
59
-	/**
60
-	 * Variable of group route.
61
-	 *  
62
-	 * @var array $groupStack
63
-	 */
64
-	protected $groupStack = [];
42
+    use Concerns\RouteMap,
43
+        Concerns\RouteResolver;
44
+
45
+    /**
46
+     * The registered route value binders.
47
+     * 
48
+     * @var array $binders
49
+     */
50
+    protected $binders = [];
51
+
52
+    /**
53
+     * The container instance used by the router.
54
+     * 
55
+     * @var \Syscodes\Contracts\Container\Container $container
56
+     */
57
+    protected $container;
58
+
59
+    /**
60
+     * Variable of group route.
61
+     *  
62
+     * @var array $groupStack
63
+     */
64
+    protected $groupStack = [];
65 65
 	
66
-	/**
67
-	 * The registered string macros.
68
-	 * 
69
-	 * @var array $macros
70
-	 */
71
-	protected $macros = [];
72
-
73
-	/**
74
-	 * Middleware for function of filters
75
-	 *  
76
-	 * @var string[] $middleware
77
-	 */
78
-	protected $middleware = [];
66
+    /**
67
+     * The registered string macros.
68
+     * 
69
+     * @var array $macros
70
+     */
71
+    protected $macros = [];
72
+
73
+    /**
74
+     * Middleware for function of filters
75
+     *  
76
+     * @var string[] $middleware
77
+     */
78
+    protected $middleware = [];
79 79
 	
80
-	/**
81
-	 * The globally available parameter patterns.
82
-	 * 
83
-	 * @var array $patterns
84
-	 */
85
-	protected $patterns = [];
86
-
87
-	/** 
88
-	 * The route collection instance. 
89
-	 * 
90
-	 * @var \Syscodes\Routing\RouteCollection $routes
91
-	 */
92
-	protected $routes;
93
-
94
-	/**
95
-	 * The Resource instance.
96
-	 * 
97
-	 * @var \Syscodes\Routing\ResourceRegister $resources
98
-	 */
99
-	protected $resources;
100
-
101
-	/**
102
-	 * Constructor. Create a new Router instance.
103
-	 *
104
-	 * @param  \Syscodes\Contracts\Container\Container|null  $container  (null by default)
105
-	 * 
106
-	 * @return void
107
-	 */
108
-	public function __construct(Container $container = null)
109
-	{
110
-		$this->routes = new RouteCollection();
111
-
112
-		$this->container = $container ?: new Container;
113
-	}
114
-
115
-	/**
116
-	 * Get the prefix from the group on the stack.
117
-	 *
118
-	 * @return string
119
-	 */
120
-	public function getGroupPrefix()
121
-	{
122
-		if ( ! empty($this->groupStack)) {
123
-			$last = end($this->groupStack);
124
-
125
-			return $last['prefix'] ?? '';
126
-		}
127
-
128
-		return '';
129
-	}
130
-
131
-	/**
132
-	 * Group a series of routes under a single URL segment. This is handy
133
-	 * for grouping items into an admin area, like:
134
-	 *
135
-	 *   Example:
136
-	 *      // Creates route: /admin show the word 'User'
137
-	 *      Route::group(['prefix' => 'admin'], function() {	 
138
-	 *
139
-	 *          Route::get('/user', function() {
140
-	 *	            echo 'Hello world..!';
141
-	 *          });
142
-	 *
143
-	 *      }); /admin/user
144
-	 *
145
-	 * @param  array  $attributes
146
-	 * @param  \Closure|string  $callback
147
-	 *
148
-	 * @return void
149
-	 */
150
-	public function group(array $attributes, $callback) 
151
-	{
152
-		$this->updateGroupStack($attributes);
153
-
154
-		$this->loadRoutes($callback);
155
-
156
-		array_pop($this->groupStack);
157
-
158
-		return $this;
159
-	}
160
-
161
-	/**
162
-	 * Update the group stack with the given attributes.
163
-	 * 
164
-	 * @param  array  $attributes
165
-	 * 
166
-	 * @return void
167
-	 */
168
-	protected function updateGroupStack(array $attributes)
169
-	{
170
-		if ( ! empty($this->groupStack)) {
171
-			$attributes = $this->mergeGroup($attributes);
172
-		}
173
-
174
-		$this->groupStack[] = $attributes;
175
-	}
176
-
177
-	/**
178
-	 * Merge the given group attributes.
179
-	 * 
180
-	 * @param  array  $new
181
-	 * 
182
-	 * @return array
183
-	 */
184
-	protected function mergeGroup($new)
185
-	{
186
-		return RouteGroup::mergeGroup($new, end($this->groupStack));
187
-	}
80
+    /**
81
+     * The globally available parameter patterns.
82
+     * 
83
+     * @var array $patterns
84
+     */
85
+    protected $patterns = [];
86
+
87
+    /** 
88
+     * The route collection instance. 
89
+     * 
90
+     * @var \Syscodes\Routing\RouteCollection $routes
91
+     */
92
+    protected $routes;
93
+
94
+    /**
95
+     * The Resource instance.
96
+     * 
97
+     * @var \Syscodes\Routing\ResourceRegister $resources
98
+     */
99
+    protected $resources;
100
+
101
+    /**
102
+     * Constructor. Create a new Router instance.
103
+     *
104
+     * @param  \Syscodes\Contracts\Container\Container|null  $container  (null by default)
105
+     * 
106
+     * @return void
107
+     */
108
+    public function __construct(Container $container = null)
109
+    {
110
+        $this->routes = new RouteCollection();
111
+
112
+        $this->container = $container ?: new Container;
113
+    }
114
+
115
+    /**
116
+     * Get the prefix from the group on the stack.
117
+     *
118
+     * @return string
119
+     */
120
+    public function getGroupPrefix()
121
+    {
122
+        if ( ! empty($this->groupStack)) {
123
+            $last = end($this->groupStack);
124
+
125
+            return $last['prefix'] ?? '';
126
+        }
127
+
128
+        return '';
129
+    }
130
+
131
+    /**
132
+     * Group a series of routes under a single URL segment. This is handy
133
+     * for grouping items into an admin area, like:
134
+     *
135
+     *   Example:
136
+     *      // Creates route: /admin show the word 'User'
137
+     *      Route::group(['prefix' => 'admin'], function() {	 
138
+     *
139
+     *          Route::get('/user', function() {
140
+     *	            echo 'Hello world..!';
141
+     *          });
142
+     *
143
+     *      }); /admin/user
144
+     *
145
+     * @param  array  $attributes
146
+     * @param  \Closure|string  $callback
147
+     *
148
+     * @return void
149
+     */
150
+    public function group(array $attributes, $callback) 
151
+    {
152
+        $this->updateGroupStack($attributes);
153
+
154
+        $this->loadRoutes($callback);
155
+
156
+        array_pop($this->groupStack);
157
+
158
+        return $this;
159
+    }
160
+
161
+    /**
162
+     * Update the group stack with the given attributes.
163
+     * 
164
+     * @param  array  $attributes
165
+     * 
166
+     * @return void
167
+     */
168
+    protected function updateGroupStack(array $attributes)
169
+    {
170
+        if ( ! empty($this->groupStack)) {
171
+            $attributes = $this->mergeGroup($attributes);
172
+        }
173
+
174
+        $this->groupStack[] = $attributes;
175
+    }
176
+
177
+    /**
178
+     * Merge the given group attributes.
179
+     * 
180
+     * @param  array  $new
181
+     * 
182
+     * @return array
183
+     */
184
+    protected function mergeGroup($new)
185
+    {
186
+        return RouteGroup::mergeGroup($new, end($this->groupStack));
187
+    }
188 188
 	
189
-	/**
190
-	 * Load the provided routes.
191
-	 * 
192
-	 * @param  \Closure|string  $callback
193
-	 * 
194
-	 * @return void
195
-	 */
196
-	protected function loadRoutes($callback)
197
-	{
198
-		if ($callback instanceof Closure) {
199
-			$callback($this);
200
-		} else {
201
-			(new RouteFileRegister($this))->register($callback);
202
-		}
203
-	}
204
-
205
-	/**
206
-	 * Add a route to the underlying route collection. 
207
-	 *
208
-	 * @param  array|string  $method
209
-	 * @param  string  $route
210
-	 * @param  mixed  $action
211
-	 *
212
-	 * @return \Syscodes\Routing\Route
213
-	 */
214
-	public function addRoute($method, $route, $action)
215
-	{
216
-		return $this->routes->add($this->map($method, $route, $action));
217
-	}
218
-
219
-	/**
220
-	 * Create a redirect from one URI to another.
221
-	 * 
222
-	 * @param  string  $uri
223
-	 * @param  string  $destination
224
-	 * @param  int  $status  (302 by default)
225
-	 * 
226
-	 * @return \Syscodes\Routing\Route
227
-	 */
228
-	public function redirect($uri, $destination, $status = 302)
229
-	{
230
-		return $this->any($uri, function () use ($destination, $status) {
231
-			return new RedirectResponse($destination, $status);
232
-		});
233
-	}
234
-
235
-	/**
236
-	 * Register a new route that returns a view.
237
-	 * 
238
-	 * @param  string  $uri
239
-	 * @param  string  $view
240
-	 * @param  array  $data
241
-	 * 
242
-	 * @return \Syscodes\Routing\Route
243
-	 */
244
-	public function view($uri, $view, $data = [])
245
-	{
246
-		return $this->match(['GET', 'HEAD'], $uri, function () use ($view, $data) {
247
-			return $this->container->make('view')->make($view, $data);
248
-		});
249
-	}
250
-
251
-	/**
252
-	 * Add new route to routes array.
253
-	 *
254
-	 * @param  array|string  $method
255
-	 * @param  string  $route
256
-	 * @param  mixed  $action
257
-	 *
258
-	 * @return void
259
-	 * 
260
-	 * @throws \InvalidArgumentException
261
-	 */
262
-	public function map($method, $route, $action) 
263
-	{
264
-		if ($this->actionReferencesController($action)) {
265
-			$action = $this->convertToControllerAction($action);
266
-		}
267
-
268
-		$route = $this->newRoute(
269
-				array_map('strtoupper', (array) $method),
270
-				$this->prefix($route),
271
-				$action
272
-		);
273
-
274
-		if ($this->hasGroupStack()) {
275
-			$this->mergeGroupAttributesIntoRoute($route);			
276
-		}
277
-
278
-		$this->addWhereClausesToRoute($route);
189
+    /**
190
+     * Load the provided routes.
191
+     * 
192
+     * @param  \Closure|string  $callback
193
+     * 
194
+     * @return void
195
+     */
196
+    protected function loadRoutes($callback)
197
+    {
198
+        if ($callback instanceof Closure) {
199
+            $callback($this);
200
+        } else {
201
+            (new RouteFileRegister($this))->register($callback);
202
+        }
203
+    }
204
+
205
+    /**
206
+     * Add a route to the underlying route collection. 
207
+     *
208
+     * @param  array|string  $method
209
+     * @param  string  $route
210
+     * @param  mixed  $action
211
+     *
212
+     * @return \Syscodes\Routing\Route
213
+     */
214
+    public function addRoute($method, $route, $action)
215
+    {
216
+        return $this->routes->add($this->map($method, $route, $action));
217
+    }
218
+
219
+    /**
220
+     * Create a redirect from one URI to another.
221
+     * 
222
+     * @param  string  $uri
223
+     * @param  string  $destination
224
+     * @param  int  $status  (302 by default)
225
+     * 
226
+     * @return \Syscodes\Routing\Route
227
+     */
228
+    public function redirect($uri, $destination, $status = 302)
229
+    {
230
+        return $this->any($uri, function () use ($destination, $status) {
231
+            return new RedirectResponse($destination, $status);
232
+        });
233
+    }
234
+
235
+    /**
236
+     * Register a new route that returns a view.
237
+     * 
238
+     * @param  string  $uri
239
+     * @param  string  $view
240
+     * @param  array  $data
241
+     * 
242
+     * @return \Syscodes\Routing\Route
243
+     */
244
+    public function view($uri, $view, $data = [])
245
+    {
246
+        return $this->match(['GET', 'HEAD'], $uri, function () use ($view, $data) {
247
+            return $this->container->make('view')->make($view, $data);
248
+        });
249
+    }
250
+
251
+    /**
252
+     * Add new route to routes array.
253
+     *
254
+     * @param  array|string  $method
255
+     * @param  string  $route
256
+     * @param  mixed  $action
257
+     *
258
+     * @return void
259
+     * 
260
+     * @throws \InvalidArgumentException
261
+     */
262
+    public function map($method, $route, $action) 
263
+    {
264
+        if ($this->actionReferencesController($action)) {
265
+            $action = $this->convertToControllerAction($action);
266
+        }
267
+
268
+        $route = $this->newRoute(
269
+                array_map('strtoupper', (array) $method),
270
+                $this->prefix($route),
271
+                $action
272
+        );
273
+
274
+        if ($this->hasGroupStack()) {
275
+            $this->mergeGroupAttributesIntoRoute($route);			
276
+        }
277
+
278
+        $this->addWhereClausesToRoute($route);
279 279
 		
280
-		return $route;
281
-	}
280
+        return $route;
281
+    }
282 282
 	
283
-	/**
284
-	 * Determine if the action is routing to a controller.
285
-	 * 
286
-	 * @param  array  $action
287
-	 * 
288
-	 * @return bool
289
-	 */
290
-	protected function actionReferencesController($action)
291
-	{
292
-		if ($action instanceof Closure) {
293
-			return false;
294
-		}
283
+    /**
284
+     * Determine if the action is routing to a controller.
285
+     * 
286
+     * @param  array  $action
287
+     * 
288
+     * @return bool
289
+     */
290
+    protected function actionReferencesController($action)
291
+    {
292
+        if ($action instanceof Closure) {
293
+            return false;
294
+        }
295 295
 		
296
-		return is_string($action) || (isset($action['uses']) && is_string($action['uses']));
297
-	}
296
+        return is_string($action) || (isset($action['uses']) && is_string($action['uses']));
297
+    }
298 298
 	
299
-	/**
300
-	 * Add a controller based route action to the action array.
301
-	 * 
302
-	 * @param  array|string  $action
303
-	 * 
304
-	 * @return array
305
-	 */
306
-	protected function convertToControllerAction($action)
307
-	{
308
-		if (is_string($action)) {
309
-			$action = ['uses' => $action];
310
-		}
299
+    /**
300
+     * Add a controller based route action to the action array.
301
+     * 
302
+     * @param  array|string  $action
303
+     * 
304
+     * @return array
305
+     */
306
+    protected function convertToControllerAction($action)
307
+    {
308
+        if (is_string($action)) {
309
+            $action = ['uses' => $action];
310
+        }
311 311
 		
312
-		if ( ! empty($this->groupStack)) {
313
-			$action['uses'] = $this->prependGroupUses($action['uses']);
314
-		}
312
+        if ( ! empty($this->groupStack)) {
313
+            $action['uses'] = $this->prependGroupUses($action['uses']);
314
+        }
315 315
 		
316
-		$action['controller'] = $action['uses'];
316
+        $action['controller'] = $action['uses'];
317 317
 		
318
-		return $action;
319
-	}
318
+        return $action;
319
+    }
320 320
 	
321
-	/**
322
-	 * Prepend the last group uses onto the use clause.
323
-	 * 
324
-	 * @param  string  $uses
325
-	 * 
326
-	 * @return string
327
-	 */
328
-	protected function prependGroupUses($uses)
329
-	{
330
-		$group = end($this->groupStack);
321
+    /**
322
+     * Prepend the last group uses onto the use clause.
323
+     * 
324
+     * @param  string  $uses
325
+     * 
326
+     * @return string
327
+     */
328
+    protected function prependGroupUses($uses)
329
+    {
330
+        $group = end($this->groupStack);
331 331
 		
332
-		return isset($group['namespace']) ? $group['namespace'].'\\'.$uses : $uses;
333
-	}
334
-
335
-	/**
336
-	 * Create a new Route object.
337
-	 * 
338
-	 * @param  array|string  $method
339
-	 * @param  string  $uri
340
-	 * @param  mixed  $action
341
-	 * 
342
-	 * @return \Syscodes\Routing\Route
343
-	 */
344
-	public function newRoute($method, $uri, $action)
345
-	{
346
-		return take(new Route($method, $uri, $action))
347
-		              ->setContainer($this->container);
348
-	}
332
+        return isset($group['namespace']) ? $group['namespace'].'\\'.$uses : $uses;
333
+    }
334
+
335
+    /**
336
+     * Create a new Route object.
337
+     * 
338
+     * @param  array|string  $method
339
+     * @param  string  $uri
340
+     * @param  mixed  $action
341
+     * 
342
+     * @return \Syscodes\Routing\Route
343
+     */
344
+    public function newRoute($method, $uri, $action)
345
+    {
346
+        return take(new Route($method, $uri, $action))
347
+                        ->setContainer($this->container);
348
+    }
349 349
 	
350
-	/**
351
-	 * Determine if the router currently has a group stack.
352
-	 * 
353
-	 * @return bool
354
-	 */
355
-	public function hasGroupStack()
356
-	{
357
-		return ! empty($this->groupStack);
358
-	}
350
+    /**
351
+     * Determine if the router currently has a group stack.
352
+     * 
353
+     * @return bool
354
+     */
355
+    public function hasGroupStack()
356
+    {
357
+        return ! empty($this->groupStack);
358
+    }
359 359
 	
360
-	/**
361
-	 * Merge the group stack with the controller action.
362
-	 * 
363
-	 * @param  \Syscpde\Routing\Route  $route
364
-	 * 
365
-	 * @return void
366
-	 */
367
-	protected function mergeGroupAttributesIntoRoute($route)
368
-	{
369
-		$action = static::mergeGroup($route->getAction(), end($this->groupStack));
360
+    /**
361
+     * Merge the group stack with the controller action.
362
+     * 
363
+     * @param  \Syscpde\Routing\Route  $route
364
+     * 
365
+     * @return void
366
+     */
367
+    protected function mergeGroupAttributesIntoRoute($route)
368
+    {
369
+        $action = static::mergeGroup($route->getAction(), end($this->groupStack));
370 370
 		
371
-		$route->setAction($action);
372
-	}
371
+        $route->setAction($action);
372
+    }
373 373
 	
374
-	/**
375
-	 * Add the necessary where clauses to the route based on its initial registration.
376
-	 * 
377
-	 * @param  \Syscodes\Routing\Route  $route
378
-	 * 
379
-	 * @return \Syscodes\Routing\Route
380
-	 */
381
-	protected function addWhereClausesToRoute($route)
382
-	{
383
-		return $route->where(array_merge(
384
-			$this->patterns, Arr::get($route->getAction(), 'where', [])
385
-		));
386
-	}
387
-
388
-	/**
389
-	 * Add a prefix to the route URI.
390
-	 *
391
-	 * @param  string  $uri
392
-	 *
393
-	 * @return string
394
-	 */
395
-	protected function prefix($uri)
396
-	{
397
-		$uri = is_null($uri) ? '' : trim($uri, '/').'/';
398
-
399
-		$uri = filter_var($uri, FILTER_SANITIZE_STRING);
400
-
401
-		// While we want to add a route within a group of '/',
402
-		// it doens't work with matching, so remove them...
403
-		if ($uri != '/') {
404
-			$uri = ltrim($uri, '/');
405
-		}
406
-
407
-		return trim(trim($this->getGroupPrefix(), '/').'/'.trim($uri, '/'), '/') ?: '/';
408
-	}
409
-
410
-	/**
411
-	 * Set a global where pattern on all routes.
412
-	 * 
413
-	 * @param  string  $name
414
-	 * @param  string  $pattern
415
-	 * 
416
-	 * @return void
417
-	 */
418
-	public function pattern($name, $pattern)
419
-	{
420
-		return $this->patterns[$name] = $pattern;
421
-	}
422
-
423
-	/**
424
-	 * Set a group of global where patterns on all routes.
425
-	 * 
426
-	 * @param  array  $patterns
427
-	 * 
428
-	 * @return void
429
-	 */
430
-	public function patterns($patterns)
431
-	{
432
-		foreach ($patterns as $key => $pattern) {
433
-			$this->patterns[$key] = $pattern;
434
-		}
435
-	}
436
-
437
-	/**
438
-	 * Get a Resource instance.
439
-	 * 
440
-	 * @return \Syscodes\Routing\ResourceRegister
441
-	 */
442
-	public function getResource()
443
-	{
444
-		if (isset($this->resources)) {
445
-			return $this->resources;
446
-		}
447
-
448
-		return $this->resources = new ResourceRegister($this);
449
-	}
450
-
451
-	/**
452
-	 * Dispatches the given url and call the method that belongs to the route.
453
-	 *
454
-	 * @param  \Syscodes\Http\Request  $request
455
-	 *
456
-	 * @return mixed
457
-	 */
458
-	public function dispatch(Request $request)
459
-	{
460
-		return $this->resolve($request, $this->routes);
461
-	}
462
-
463
-	/**
464
-	 * Check if a route with the given name exists.
465
-	 * 
466
-	 * @param  string  $name
467
-	 * 
468
-	 * @return bool
469
-	 */
470
-	public function has($name)
471
-	{
472
-		$names = is_array($name) ? $name : func_get_args();
473
-
474
-		foreach ($names as $value) {
475
-			if ( ! $this->routes->hasNamedRoute($value)) {
476
-				return false;
477
-			}
478
-		}
479
-
480
-		return true;
481
-	}
482
-
483
-	/**
484
-	 * Get the currently dispatched route instance.
485
-	 * 
486
-	 * @return \Syscodes\Routing\Route|null
487
-	 */
488
-	public function current()
489
-	{
490
-		return $this->current;
491
-	}
492
-
493
-	/**
494
-	 * Determine if the current route matches a pattern.
495
-	 * 
496
-	 * @param  mixed  ...$patterns
497
-	 * 
498
-	 * @return bool
499
-	 */
500
-	public function is(...$patterns)
501
-	{
502
-		return $this->currentRouteNamed(...$patterns);
503
-	}
504
-
505
-	/**
506
-	 * Determine if the current route matches a pattern.
507
-	 * 
508
-	 * @param  mixed  ...$patterns
509
-	 * 
510
-	 * @return bool
511
-	 */
512
-	public function currentRouteNamed(...$patterns)
513
-	{
514
-		return $this->current() && $this->current()->named(...$patterns);
515
-	}
516
-
517
-	/**
518
-	 * Register an array of resource controllers.
519
-	 * 
520
-	 * @param  array  $resources
521
-	 * @param  array  $options
522
-	 * 
523
-	 * @return void
524
-	 */
525
-	public function resources(array $resources, array $options = [])
526
-	{
527
-		foreach ($resources as $name => $controller) {
528
-			$this->resource($name, $controller, $options);
529
-		}
530
-	}
531
-
532
-	/**
533
-	 * Route a resource to a controller.
534
-	 * 
535
-	 * @param  string  $name
536
-	 * @param  string  $controller
537
-	 * @param  array  $options
538
-	 * 
539
-	 * @return \Syscodes\Routing\AwaitingResourceRegistration
540
-	 */
541
-	public function resource($name, $controller, array $options = []) 
542
-	{
543
-		if ($this->container) {
544
-			$register = $this->container->make(ResourceRegister::class);
545
-		} else {
546
-			$register = new ResourceRegister($this);
547
-		}
548
-
549
-		return new AwaitingResourceRegistration(
550
-			$register, $name, $controller, $options
551
-		);
552
-	}
553
-
554
-	/**
555
-	 * Get the route collection.
556
-	 *
557
-	 * @return array   
558
-	 */
559
-	public function getRoutes()
560
-	{
561
-		return $this->routes;
562
-	}
563
-
564
-	/**
565
-	 * Get or set the verbs used in the resource URIs.
566
-	 * 
567
-	 * @param  array  $verbs
568
-	 * 
569
-	 * @return array|null
570
-	 */
571
-	public function resourceVerbs(array $verbs = [])
572
-	{
573
-		ResourceRegister::verbs($verbs);
574
-	}
374
+    /**
375
+     * Add the necessary where clauses to the route based on its initial registration.
376
+     * 
377
+     * @param  \Syscodes\Routing\Route  $route
378
+     * 
379
+     * @return \Syscodes\Routing\Route
380
+     */
381
+    protected function addWhereClausesToRoute($route)
382
+    {
383
+        return $route->where(array_merge(
384
+            $this->patterns, Arr::get($route->getAction(), 'where', [])
385
+        ));
386
+    }
387
+
388
+    /**
389
+     * Add a prefix to the route URI.
390
+     *
391
+     * @param  string  $uri
392
+     *
393
+     * @return string
394
+     */
395
+    protected function prefix($uri)
396
+    {
397
+        $uri = is_null($uri) ? '' : trim($uri, '/').'/';
398
+
399
+        $uri = filter_var($uri, FILTER_SANITIZE_STRING);
400
+
401
+        // While we want to add a route within a group of '/',
402
+        // it doens't work with matching, so remove them...
403
+        if ($uri != '/') {
404
+            $uri = ltrim($uri, '/');
405
+        }
406
+
407
+        return trim(trim($this->getGroupPrefix(), '/').'/'.trim($uri, '/'), '/') ?: '/';
408
+    }
409
+
410
+    /**
411
+     * Set a global where pattern on all routes.
412
+     * 
413
+     * @param  string  $name
414
+     * @param  string  $pattern
415
+     * 
416
+     * @return void
417
+     */
418
+    public function pattern($name, $pattern)
419
+    {
420
+        return $this->patterns[$name] = $pattern;
421
+    }
422
+
423
+    /**
424
+     * Set a group of global where patterns on all routes.
425
+     * 
426
+     * @param  array  $patterns
427
+     * 
428
+     * @return void
429
+     */
430
+    public function patterns($patterns)
431
+    {
432
+        foreach ($patterns as $key => $pattern) {
433
+            $this->patterns[$key] = $pattern;
434
+        }
435
+    }
436
+
437
+    /**
438
+     * Get a Resource instance.
439
+     * 
440
+     * @return \Syscodes\Routing\ResourceRegister
441
+     */
442
+    public function getResource()
443
+    {
444
+        if (isset($this->resources)) {
445
+            return $this->resources;
446
+        }
447
+
448
+        return $this->resources = new ResourceRegister($this);
449
+    }
450
+
451
+    /**
452
+     * Dispatches the given url and call the method that belongs to the route.
453
+     *
454
+     * @param  \Syscodes\Http\Request  $request
455
+     *
456
+     * @return mixed
457
+     */
458
+    public function dispatch(Request $request)
459
+    {
460
+        return $this->resolve($request, $this->routes);
461
+    }
462
+
463
+    /**
464
+     * Check if a route with the given name exists.
465
+     * 
466
+     * @param  string  $name
467
+     * 
468
+     * @return bool
469
+     */
470
+    public function has($name)
471
+    {
472
+        $names = is_array($name) ? $name : func_get_args();
473
+
474
+        foreach ($names as $value) {
475
+            if ( ! $this->routes->hasNamedRoute($value)) {
476
+                return false;
477
+            }
478
+        }
479
+
480
+        return true;
481
+    }
482
+
483
+    /**
484
+     * Get the currently dispatched route instance.
485
+     * 
486
+     * @return \Syscodes\Routing\Route|null
487
+     */
488
+    public function current()
489
+    {
490
+        return $this->current;
491
+    }
492
+
493
+    /**
494
+     * Determine if the current route matches a pattern.
495
+     * 
496
+     * @param  mixed  ...$patterns
497
+     * 
498
+     * @return bool
499
+     */
500
+    public function is(...$patterns)
501
+    {
502
+        return $this->currentRouteNamed(...$patterns);
503
+    }
504
+
505
+    /**
506
+     * Determine if the current route matches a pattern.
507
+     * 
508
+     * @param  mixed  ...$patterns
509
+     * 
510
+     * @return bool
511
+     */
512
+    public function currentRouteNamed(...$patterns)
513
+    {
514
+        return $this->current() && $this->current()->named(...$patterns);
515
+    }
516
+
517
+    /**
518
+     * Register an array of resource controllers.
519
+     * 
520
+     * @param  array  $resources
521
+     * @param  array  $options
522
+     * 
523
+     * @return void
524
+     */
525
+    public function resources(array $resources, array $options = [])
526
+    {
527
+        foreach ($resources as $name => $controller) {
528
+            $this->resource($name, $controller, $options);
529
+        }
530
+    }
531
+
532
+    /**
533
+     * Route a resource to a controller.
534
+     * 
535
+     * @param  string  $name
536
+     * @param  string  $controller
537
+     * @param  array  $options
538
+     * 
539
+     * @return \Syscodes\Routing\AwaitingResourceRegistration
540
+     */
541
+    public function resource($name, $controller, array $options = []) 
542
+    {
543
+        if ($this->container) {
544
+            $register = $this->container->make(ResourceRegister::class);
545
+        } else {
546
+            $register = new ResourceRegister($this);
547
+        }
548
+
549
+        return new AwaitingResourceRegistration(
550
+            $register, $name, $controller, $options
551
+        );
552
+    }
553
+
554
+    /**
555
+     * Get the route collection.
556
+     *
557
+     * @return array   
558
+     */
559
+    public function getRoutes()
560
+    {
561
+        return $this->routes;
562
+    }
563
+
564
+    /**
565
+     * Get or set the verbs used in the resource URIs.
566
+     * 
567
+     * @param  array  $verbs
568
+     * 
569
+     * @return array|null
570
+     */
571
+    public function resourceVerbs(array $verbs = [])
572
+    {
573
+        ResourceRegister::verbs($verbs);
574
+    }
575 575
 	
576
-	/**
577
-	 * Register a custom macro.
578
-	 * 
579
-	 * @param  string  $name
580
-	 * @param  callable  $callback
581
-	 * 
582
-	 * @return void
583
-	 */
584
-	public function macro($name, callable $callback)
585
-	{
586
-		$this->macros[$name] = $callback;
587
-	}
576
+    /**
577
+     * Register a custom macro.
578
+     * 
579
+     * @param  string  $name
580
+     * @param  callable  $callback
581
+     * 
582
+     * @return void
583
+     */
584
+    public function macro($name, callable $callback)
585
+    {
586
+        $this->macros[$name] = $callback;
587
+    }
588 588
 	
589
-	/**
590
-	 * Checks if macro is registered.
591
-	 * 
592
-	 * @param  string  $name
593
-	 * 
594
-	 * @return boolean
595
-	 */
596
-	public function hasMacro($name)
597
-	{
598
-		return isset($this->macros[$name]);
599
-	}
589
+    /**
590
+     * Checks if macro is registered.
591
+     * 
592
+     * @param  string  $name
593
+     * 
594
+     * @return boolean
595
+     */
596
+    public function hasMacro($name)
597
+    {
598
+        return isset($this->macros[$name]);
599
+    }
600 600
 	
601
-	/**
602
-	 * Dynamically handle calls into the router instance.
603
-	 * 
604
-	 * @param  string  $method
605
-	 * @param  array  $parameters
606
-	 * 
607
-	 * @return mixed
608
-	 */
609
-	public function __call($method, $parameters)
610
-	{
611
-		if (isset($this->macros[$method])) {
612
-			$callback = $this->macros[$method];
613
-
614
-			return call_user_func_array($callback, $parameters);
615
-		}
601
+    /**
602
+     * Dynamically handle calls into the router instance.
603
+     * 
604
+     * @param  string  $method
605
+     * @param  array  $parameters
606
+     * 
607
+     * @return mixed
608
+     */
609
+    public function __call($method, $parameters)
610
+    {
611
+        if (isset($this->macros[$method])) {
612
+            $callback = $this->macros[$method];
613
+
614
+            return call_user_func_array($callback, $parameters);
615
+        }
616 616
 		
617
-		return (new RouteRegister($this))->attribute($method, $parameters[0]);
618
-	}
617
+        return (new RouteRegister($this))->attribute($method, $parameters[0]);
618
+    }
619 619
 }
620 620
\ 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
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function redirect($uri, $destination, $status = 302)
229 229
 	{
230
-		return $this->any($uri, function () use ($destination, $status) {
230
+		return $this->any($uri, function() use ($destination, $status) {
231 231
 			return new RedirectResponse($destination, $status);
232 232
 		});
233 233
 	}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function view($uri, $view, $data = [])
245 245
 	{
246
-		return $this->match(['GET', 'HEAD'], $uri, function () use ($view, $data) {
246
+		return $this->match(['GET', 'HEAD'], $uri, function() use ($view, $data) {
247 247
 			return $this->container->make('view')->make($view, $data);
248 248
 		});
249 249
 	}
Please login to merge, or discard this patch.
src/components/Routing/RouteGroup.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -31,97 +31,97 @@
 block discarded – undo
31 31
  */
32 32
 class RouteGroup
33 33
 {
34
- 	/**
35
-	 * Merge the given group attributes.
36
-	 * 
37
-	 * @param  array  $new
38
-	 * @param  array  $old
39
-	 * 
40
-	 * @return array
41
-	 */
42
-	public static function mergeGroup($new, $old)
43
-	{
44
-		if (isset($new['domain'])) {
45
-			unset($old['domain']);
46
-		}
34
+        /**
35
+         * Merge the given group attributes.
36
+         * 
37
+         * @param  array  $new
38
+         * @param  array  $old
39
+         * 
40
+         * @return array
41
+         */
42
+    public static function mergeGroup($new, $old)
43
+    {
44
+        if (isset($new['domain'])) {
45
+            unset($old['domain']);
46
+        }
47 47
 
48
-		$new = array_merge(static::formatUseAs($new, $old), [
48
+        $new = array_merge(static::formatUseAs($new, $old), [
49 49
             'namespace' => static::formatUseNamespace($new, $old),
50 50
             'prefix' => static::formatUsePrefix($new, $old),
51 51
             'where' => static::formatUseWhere($new, $old)
52 52
         ]);
53 53
 		
54
-		return array_merge_recursive(
55
-			Arr::except($old, array('namespace', 'prefix', 'where', 'as')), $new
56
-		);
57
-	}
54
+        return array_merge_recursive(
55
+            Arr::except($old, array('namespace', 'prefix', 'where', 'as')), $new
56
+        );
57
+    }
58 58
 
59
-	/**
60
-	 * Format the uses namespace for the new group attributes.
61
-	 * 
62
-	 * @param  array  $new
63
-	 * @param  array  $old
64
-	 * 
65
-	 * @return string|null
66
-	 */
67
-	protected static function formatUseNamespace($new, $old)
68
-	{
69
-		if (isset($new['namespace'])) {
70
-			return isset($old['namespace'])
71
-				   ? trim($old['namespace'], '\\').'\\'.trim($new['namespace'], '\\')
72
-				   : trim($new['namespace'], '\\');
73
-		}
59
+    /**
60
+     * Format the uses namespace for the new group attributes.
61
+     * 
62
+     * @param  array  $new
63
+     * @param  array  $old
64
+     * 
65
+     * @return string|null
66
+     */
67
+    protected static function formatUseNamespace($new, $old)
68
+    {
69
+        if (isset($new['namespace'])) {
70
+            return isset($old['namespace'])
71
+                   ? trim($old['namespace'], '\\').'\\'.trim($new['namespace'], '\\')
72
+                   : trim($new['namespace'], '\\');
73
+        }
74 74
 
75
-		return $old['namespace'] ?? null;
76
-	}
75
+        return $old['namespace'] ?? null;
76
+    }
77 77
 
78
-	/**
79
-	 * Format the prefix for the new group attributes.
80
-	 * 
81
-	 * @param  array  $new
82
-	 * @param  array  $old
83
-	 * 
84
-	 * @return string|null
85
-	 */
86
-	protected static function formatUsePrefix($new, $old)
87
-	{
88
-		$old = $old['prefix'] ?? null;
78
+    /**
79
+     * Format the prefix for the new group attributes.
80
+     * 
81
+     * @param  array  $new
82
+     * @param  array  $old
83
+     * 
84
+     * @return string|null
85
+     */
86
+    protected static function formatUsePrefix($new, $old)
87
+    {
88
+        $old = $old['prefix'] ?? null;
89 89
 
90
-		return isset($new['prefix']) 
91
-					? trim($old, '/').'/'.trim($new['prefix'], '/')
92
-					: $old;
93
-	}
90
+        return isset($new['prefix']) 
91
+                    ? trim($old, '/').'/'.trim($new['prefix'], '/')
92
+                    : $old;
93
+    }
94 94
 
95
-	/**
96
-	 * Format the "wheres" for the new group attributes.
97
-	 * 
98
-	 * @param  array  $new
99
-	 * @param  array  $old
100
-	 * 
101
-	 * @return array
102
-	 */
103
-	protected static function formatUseWhere($new, $old)
104
-	{
105
-		return array_merge(
106
-			$old['where'] ?? [],
107
-			$new['where'] ?? []
108
-		);
109
-	}
95
+    /**
96
+     * Format the "wheres" for the new group attributes.
97
+     * 
98
+     * @param  array  $new
99
+     * @param  array  $old
100
+     * 
101
+     * @return array
102
+     */
103
+    protected static function formatUseWhere($new, $old)
104
+    {
105
+        return array_merge(
106
+            $old['where'] ?? [],
107
+            $new['where'] ?? []
108
+        );
109
+    }
110 110
 
111
-	/**
112
-	 * Format the "as" clause of the new group attributes.
113
-	 * 
114
-	 * @param  array  $new
115
-	 * @param  array  $old
116
-	 * 
117
-	 * @return array
118
-	 */
119
-	protected static function formatUseAs($new, $old)
120
-	{
121
-		if (isset($old['as'])) {
111
+    /**
112
+     * Format the "as" clause of the new group attributes.
113
+     * 
114
+     * @param  array  $new
115
+     * @param  array  $old
116
+     * 
117
+     * @return array
118
+     */
119
+    protected static function formatUseAs($new, $old)
120
+    {
121
+        if (isset($old['as'])) {
122 122
             $new['as'] = $old['as'].($new['as'] ?? '');
123 123
         }
124 124
 
125
-		return $new;
126
-	}
125
+        return $new;
126
+    }
127 127
 }
128 128
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/Routing/RouteParamBinding.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 
96 96
         $parameters = array_intersect_key($matches, array_values($parameterNames));
97 97
         
98
-        return array_filter($parameters, function ($value) {
98
+        return array_filter($parameters, function($value) {
99 99
             return (is_string($value) && strlen($value) > 0);
100 100
         });
101 101
     }
Please login to merge, or discard this patch.