Passed
Push — 0.7.0 ( b9ea06...f83a91 )
by Alexander
03:05 queued 11s
created
src/components/Core/Http/Lenevor.php 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -39,272 +39,272 @@
 block discarded – undo
39 39
  */
40 40
 class Lenevor implements LenevorContract
41 41
 {
42
-	/**
43
-	 * The application implementation.
44
-	 * 
45
-	 * @var \Syscodes\Contracts\Core\Application $app
46
-	 */
47
-	protected $app;
42
+    /**
43
+     * The application implementation.
44
+     * 
45
+     * @var \Syscodes\Contracts\Core\Application $app
46
+     */
47
+    protected $app;
48 48
 	
49
-	/**
50
-	 * The bootstrap classes for the application.
51
-	 * 
52
-	 * @var array $bootstrappers
53
-	 */
54
-	protected $bootstrappers = [
55
-		\Syscodes\Core\Bootstrap\BootDetectEnvironment::class,
56
-		\Syscodes\Core\Bootstrap\BootConfiguration::class,
57
-		\Syscodes\Core\Bootstrap\BootHandleExceptions::class,
58
-		\Syscodes\Core\Bootstrap\BootRegisterFacades::class,
59
-		\Syscodes\Core\Bootstrap\BootRegisterProviders::class,
60
-		\Syscodes\Core\Bootstrap\BootProviders::class,
61
-	];
49
+    /**
50
+     * The bootstrap classes for the application.
51
+     * 
52
+     * @var array $bootstrappers
53
+     */
54
+    protected $bootstrappers = [
55
+        \Syscodes\Core\Bootstrap\BootDetectEnvironment::class,
56
+        \Syscodes\Core\Bootstrap\BootConfiguration::class,
57
+        \Syscodes\Core\Bootstrap\BootHandleExceptions::class,
58
+        \Syscodes\Core\Bootstrap\BootRegisterFacades::class,
59
+        \Syscodes\Core\Bootstrap\BootRegisterProviders::class,
60
+        \Syscodes\Core\Bootstrap\BootProviders::class,
61
+    ];
62 62
 
63
-	/**
64
-	 * Get the application's middleware.
65
-	 * 
66
-	 * @var array $middleware
67
-	 */
68
-	protected $middleware = [];
63
+    /**
64
+     * Get the application's middleware.
65
+     * 
66
+     * @var array $middleware
67
+     */
68
+    protected $middleware = [];
69 69
 
70
-	/**
71
-	 * Get the application's middleware groups.
72
-	 * 
73
-	 * @var array $middlewareGroups
74
-	 */
75
-	protected $middlewareGroups = [];
70
+    /**
71
+     * Get the application's middleware groups.
72
+     * 
73
+     * @var array $middlewareGroups
74
+     */
75
+    protected $middlewareGroups = [];
76 76
 
77
-	/**
78
-	 * The router instance.
79
-	 * 
80
-	 * @var \Syscodes\Routing\Router $router
81
-	 */
82
-	protected $router;
77
+    /**
78
+     * The router instance.
79
+     * 
80
+     * @var \Syscodes\Routing\Router $router
81
+     */
82
+    protected $router;
83 83
 
84
-	/**
85
-	 * Get the application's route middleware.
86
-	 * 
87
-	 * @var array $routeMiddleware
88
-	 */
89
-	protected $routeMiddleware = [];
84
+    /**
85
+     * Get the application's route middleware.
86
+     * 
87
+     * @var array $routeMiddleware
88
+     */
89
+    protected $routeMiddleware = [];
90 90
 
91
-	/**
92
-	 * Total app execution time.
93
-	 * 
94
-	 * @var float $totalTime
95
-	 */
96
-	protected $totalTime;
91
+    /**
92
+     * Total app execution time.
93
+     * 
94
+     * @var float $totalTime
95
+     */
96
+    protected $totalTime;
97 97
 
98
-	/**
99
-	 * Constructor. Lenevor class instance.
100
-	 * 
101
-	 * @param  \Syscodes\Contracts\Core\Application  $app
102
-	 * @param  \Syscodes\Routing\Router  $router
103
-	 * 
104
-	 * @return void
105
-	 */
106
-	public function __construct(Application $app, Router $router)
107
-	{
108
-		$this->app    = $app;
109
-		$this->router = $router;
98
+    /**
99
+     * Constructor. Lenevor class instance.
100
+     * 
101
+     * @param  \Syscodes\Contracts\Core\Application  $app
102
+     * @param  \Syscodes\Routing\Router  $router
103
+     * 
104
+     * @return void
105
+     */
106
+    public function __construct(Application $app, Router $router)
107
+    {
108
+        $this->app    = $app;
109
+        $this->router = $router;
110 110
 
111
-		$this->syncMiddlewareRoute();
112
-	}
111
+        $this->syncMiddlewareRoute();
112
+    }
113 113
 	 
114
-	/**
115
-	 * Initializes the framework, this can only be called once.
116
-	 * Launch the application.
117
-	 * 
118
-	 * @param  \Syscodes\http\Request  $request
119
-	 *
120
-	 * @return \Syscodes\Http\Response
121
-	 */
122
-	public function handle($request)
123
-	{
124
-		try {
125
-			$response = $this->sendRequestThroughRouter($request);
126
-		} catch (Throwable $e) {
127
-			$this->reportException($e);
114
+    /**
115
+     * Initializes the framework, this can only be called once.
116
+     * Launch the application.
117
+     * 
118
+     * @param  \Syscodes\http\Request  $request
119
+     *
120
+     * @return \Syscodes\Http\Response
121
+     */
122
+    public function handle($request)
123
+    {
124
+        try {
125
+            $response = $this->sendRequestThroughRouter($request);
126
+        } catch (Throwable $e) {
127
+            $this->reportException($e);
128 128
 
129
-			$response = $this->renderException($request, $e);
130
-		}		
129
+            $response = $this->renderException($request, $e);
130
+        }		
131 131
 
132
-		return $response;
133
-	}
132
+        return $response;
133
+    }
134 134
 
135
-	/**
136
-	 * Send the given request through the router.
137
-	 * 
138
-	 * @param  \Syscodes\Http\Request  $request
139
-	 * 
140
-	 * @return \Syscodes\Http\Response
141
-	 */
142
-	protected function sendRequestThroughRouter($request)
143
-	{
144
-		$this->app->instance('request', $request);  
135
+    /**
136
+     * Send the given request through the router.
137
+     * 
138
+     * @param  \Syscodes\Http\Request  $request
139
+     * 
140
+     * @return \Syscodes\Http\Response
141
+     */
142
+    protected function sendRequestThroughRouter($request)
143
+    {
144
+        $this->app->instance('request', $request);  
145 145
 
146
-		Facade::clearResolvedInstance('request');
146
+        Facade::clearResolvedInstance('request');
147 147
 
148
-		// Load configuration system
149
-		$this->bootstrap();
148
+        // Load configuration system
149
+        $this->bootstrap();
150 150
 
151
-		return (new Pipeline($this->app))
152
-				->send($request)
153
-				->through($this->app->skipGoingMiddleware() ? [] : $this->middleware)
154
-				->then($this->dispatchToRouter());
155
-	}
151
+        return (new Pipeline($this->app))
152
+                ->send($request)
153
+                ->through($this->app->skipGoingMiddleware() ? [] : $this->middleware)
154
+                ->then($this->dispatchToRouter());
155
+    }
156 156
 
157
-	/**
158
-	 * Bootstrap the application for HTTP requests.
159
-	 * 
160
-	 * @return void
161
-	 */
162
-	protected function bootstrap()
163
-	{		
164
-		if ( ! $this->app->hasBeenBootstrapped()) {
165
-			$this->app->bootstrapWith($this->bootstrappers());
166
-		}
167
-	}
157
+    /**
158
+     * Bootstrap the application for HTTP requests.
159
+     * 
160
+     * @return void
161
+     */
162
+    protected function bootstrap()
163
+    {		
164
+        if ( ! $this->app->hasBeenBootstrapped()) {
165
+            $this->app->bootstrapWith($this->bootstrappers());
166
+        }
167
+    }
168 168
 
169
-	/**
170
-	 * Get the bootstrap classes for the application.
171
-	 * 
172
-	 * @return array
173
-	 */
174
-	protected function bootstrappers()
175
-	{
176
-		return $this->bootstrappers;
177
-	}
169
+    /**
170
+     * Get the bootstrap classes for the application.
171
+     * 
172
+     * @return array
173
+     */
174
+    protected function bootstrappers()
175
+    {
176
+        return $this->bootstrappers;
177
+    }
178 178
 
179
-	/**
180
-	 * Sync the current state of the middleware to the router.
181
-	 * 
182
-	 * @return void
183
-	 */
184
-	protected function syncMiddlewareRoute()
185
-	{
186
-		foreach ($this->middlewareGroups as $key => $middleware) {
187
-			$this->router->middlewareGroup($key, $middleware);
188
-		}
179
+    /**
180
+     * Sync the current state of the middleware to the router.
181
+     * 
182
+     * @return void
183
+     */
184
+    protected function syncMiddlewareRoute()
185
+    {
186
+        foreach ($this->middlewareGroups as $key => $middleware) {
187
+            $this->router->middlewareGroup($key, $middleware);
188
+        }
189 189
 
190
-		foreach ($this->routeMiddleware as $key => $middleware) {
191
-			$this->router->aliasMiddleware($key, $middleware);
192
-		}
193
-	}
190
+        foreach ($this->routeMiddleware as $key => $middleware) {
191
+            $this->router->aliasMiddleware($key, $middleware);
192
+        }
193
+    }
194 194
 
195
-	/**
196
-	 * Get the dispatcher of routes.
197
-	 * 	  
198
-	 * @return \Closure
199
- 	 */
200
-	protected function dispatchToRouter()
201
-	{
202
-		return function ($request) {
203
-			$this->app->instance('request', $request);
195
+    /**
196
+     * Get the dispatcher of routes.
197
+     * 	  
198
+     * @return \Closure
199
+     */
200
+    protected function dispatchToRouter()
201
+    {
202
+        return function ($request) {
203
+            $this->app->instance('request', $request);
204 204
 
205
-			return $this->router->dispatch($request);
206
-		};
207
-	}
205
+            return $this->router->dispatch($request);
206
+        };
207
+    }
208 208
 
209
-	/**
210
-	 * Call the shutdown method on any terminable middleware.
211
-	 * 
212
-	 * @param  \Syscodes\Http\Request  $request
213
-	 * @param  \Syscodes\Http\Response  $response
214
-	 * 
215
-	 * @return void
216
-	 */
217
-	public function shutdown($request, $response)
218
-	{
219
-		$this->shutdownMiddleware($request, $response);
220
-	}
209
+    /**
210
+     * Call the shutdown method on any terminable middleware.
211
+     * 
212
+     * @param  \Syscodes\Http\Request  $request
213
+     * @param  \Syscodes\Http\Response  $response
214
+     * 
215
+     * @return void
216
+     */
217
+    public function shutdown($request, $response)
218
+    {
219
+        $this->shutdownMiddleware($request, $response);
220
+    }
221 221
 
222
-	/**
223
-	 * Call the terminate method on any terminable middleware.
224
-	 * 
225
-	 * @param  \Syscodes\Http\Request  $request
226
-	 * @param  \Syscodes\Http\Response  $response
227
-	 * 
228
-	 * @return void
229
-	 */
230
-	protected function shutdownMiddleware($request, $response)
231
-	{
232
-		$middlewares = $this->app->skipGoingMiddleware() ? [] : array_merge(
233
-			$this->gatherRouteMiddleware($request),
234
-			$this->middleware
235
-		);
222
+    /**
223
+     * Call the terminate method on any terminable middleware.
224
+     * 
225
+     * @param  \Syscodes\Http\Request  $request
226
+     * @param  \Syscodes\Http\Response  $response
227
+     * 
228
+     * @return void
229
+     */
230
+    protected function shutdownMiddleware($request, $response)
231
+    {
232
+        $middlewares = $this->app->skipGoingMiddleware() ? [] : array_merge(
233
+            $this->gatherRouteMiddleware($request),
234
+            $this->middleware
235
+        );
236 236
 
237
-		foreach ($middlewares as $middleware) {
238
-			if (! is_string($middleware)) {
239
-				continue;
240
-			}
237
+        foreach ($middlewares as $middleware) {
238
+            if (! is_string($middleware)) {
239
+                continue;
240
+            }
241 241
 			
242
-			[$name] = $this->parseMiddleware($middleware);
242
+            [$name] = $this->parseMiddleware($middleware);
243 243
 			
244
-			$instance = $this->app->make($name);
244
+            $instance = $this->app->make($name);
245 245
 			
246
-			if (method_exists($instance, 'shutdown')) {
247
-				$instance->shutdown($request, $response);
248
-			}
249
-		}
250
-	}
246
+            if (method_exists($instance, 'shutdown')) {
247
+                $instance->shutdown($request, $response);
248
+            }
249
+        }
250
+    }
251 251
 
252
-	/**
253
-	 * Gather the route middleware for the given request.
254
-	 * 
255
-	 * @param  \Syscodes\Http\Request  $request
256
-	 * 
257
-	 * @return array
258
-	 */
259
-	protected function gatherRouteMiddleware($request)
260
-	{
261
-		if ( ! is_null($route = $request->route())) {
262
-			return $this->router->gatherRouteMiddleware($route);
263
-		}
252
+    /**
253
+     * Gather the route middleware for the given request.
254
+     * 
255
+     * @param  \Syscodes\Http\Request  $request
256
+     * 
257
+     * @return array
258
+     */
259
+    protected function gatherRouteMiddleware($request)
260
+    {
261
+        if ( ! is_null($route = $request->route())) {
262
+            return $this->router->gatherRouteMiddleware($route);
263
+        }
264 264
 
265
-		return [];
266
-	}
265
+        return [];
266
+    }
267 267
 	
268
-	/**
269
-	 * Parse a middleware string to get the name and parameters.
270
-	 * 
271
-	 * @param  string  $middleware
272
-	 * 
273
-	 * @return array
274
-	 */
275
-	protected function parseMiddleware($middleware)
276
-	{
277
-		[$name, $parameters] = array_pad(explode(':', $middleware, 2), 2, []);
268
+    /**
269
+     * Parse a middleware string to get the name and parameters.
270
+     * 
271
+     * @param  string  $middleware
272
+     * 
273
+     * @return array
274
+     */
275
+    protected function parseMiddleware($middleware)
276
+    {
277
+        [$name, $parameters] = array_pad(explode(':', $middleware, 2), 2, []);
278 278
 		
279
-		if (is_string($parameters)) {
280
-			$parameters = explode(',', $parameters);
281
-		}
279
+        if (is_string($parameters)) {
280
+            $parameters = explode(',', $parameters);
281
+        }
282 282
 		
283
-		return [$name, $parameters];
283
+        return [$name, $parameters];
284 284
     }
285 285
 
286
-	/**
287
-	 * Report the exception to the exception handler.
288
-	 * 
289
-	 * @param  \Throwable  $e
290
-	 * 
291
-	 * @return void
292
-	 */
293
-	protected function reportException(Throwable $e)
294
-	{
295
-		return $this->app[ExceptionHandler::class]->report($e);
296
-	}
286
+    /**
287
+     * Report the exception to the exception handler.
288
+     * 
289
+     * @param  \Throwable  $e
290
+     * 
291
+     * @return void
292
+     */
293
+    protected function reportException(Throwable $e)
294
+    {
295
+        return $this->app[ExceptionHandler::class]->report($e);
296
+    }
297 297
 	
298
-	/**
299
-	 * Render the exception to a response.
300
-	 * 
301
-	 * @param  \Syscodes\Http\Request  $request
302
-	 * @param  \Throwable  $e
303
-	 * 
304
-	 * @return \Syscodes\Http\Response
305
-	 */
306
-	protected function renderException($request, Throwable $e)
307
-	{
308
-		return $this->app[ExceptionHandler::class]->render($request, $e);
309
-	}
310
- }
311 298
\ No newline at end of file
299
+    /**
300
+     * Render the exception to a response.
301
+     * 
302
+     * @param  \Syscodes\Http\Request  $request
303
+     * @param  \Throwable  $e
304
+     * 
305
+     * @return \Syscodes\Http\Response
306
+     */
307
+    protected function renderException($request, Throwable $e)
308
+    {
309
+        return $this->app[ExceptionHandler::class]->render($request, $e);
310
+    }
311
+    }
312 312
\ No newline at end of file
Please login to merge, or discard this patch.