Completed
Push — master ( 36a006...f90c70 )
by CodexShaper
04:12
created
app/Post.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		parent::boot();
84 84
 		static::addGlobalScope(
85 85
 			'type',
86
-			function ( Builder $builder ) {
87
-				$builder->where( 'post_type', '=', static::$type_scope );
86
+			function(Builder $builder) {
87
+				$builder->where('post_type', '=', static::$type_scope);
88 88
 			}
89 89
 		);
90 90
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return mixed
100 100
 	 */
101
-	public function scopeType( Builder $builder, $type ) {
101
+	public function scopeType(Builder $builder, $type) {
102 102
 		self::$type_scope = $type;
103
-		return $builder->where( 'post_type', '=', $type );
103
+		return $builder->where('post_type', '=', $type);
104 104
 	}
105 105
 
106 106
 	/**
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return mixed
113 113
 	 */
114
-	public function scopeStatus( Builder $builder, $status ) {
115
-		return $builder->where( 'post_status', '=', $status );
114
+	public function scopeStatus(Builder $builder, $status) {
115
+		return $builder->where('post_status', '=', $status);
116 116
 	}
117 117
 
118 118
 	/**
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return mixed
125 125
 	 */
126
-	public function scopeAuthor( Builder $builder, $author ) {
127
-		if ( $author ) {
128
-			return $builder->where( 'post_author', '=', $author );
126
+	public function scopeAuthor(Builder $builder, $author) {
127
+		if ($author) {
128
+			return $builder->where('post_author', '=', $author);
129 129
 		}
130 130
 	}
131 131
 }
Please login to merge, or discard this patch.
app/Http/Middleware/AuthMiddleware.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return mixed
42 42
 	 */
43
-	public function handle( Request $request, Closure $next, ...$guards ) {
44
-		foreach ( $guards as $guard ) {
45
-			if ( $guard == 'api' ) {
46
-				if ( ! Schema::hasTable( 'oauth_access_tokens' ) ||
47
-					! Schema::hasTable( 'oauth_refresh_tokens' ) ||
48
-					! Schema::hasTable( 'oauth_personal_access_clients' ) ||
49
-					! Schema::hasTable( 'oauth_clients' ) ||
50
-					! Schema::hasTable( 'oauth_auth_codes' )
43
+	public function handle(Request $request, Closure $next, ...$guards) {
44
+		foreach ($guards as $guard) {
45
+			if ($guard == 'api') {
46
+				if (!Schema::hasTable('oauth_access_tokens') ||
47
+					!Schema::hasTable('oauth_refresh_tokens') ||
48
+					!Schema::hasTable('oauth_personal_access_clients') ||
49
+					!Schema::hasTable('oauth_clients') ||
50
+					!Schema::hasTable('oauth_auth_codes')
51 51
 				) {
52
-					throw new \Exception( 'Please install OAuth2 Server Plugin (plugin link) or Implement OAuth2 Server from this link (https://github.com/Codexshaper/oauth2)', 1 );
52
+					throw new \Exception('Please install OAuth2 Server Plugin (plugin link) or Implement OAuth2 Server from this link (https://github.com/Codexshaper/oauth2)', 1);
53 53
 				}
54 54
 
55 55
 				$manager         = new Manager();
@@ -57,37 +57,37 @@  discard block
 block discarded – undo
57 57
 				$psr_request     = ServerRequest::getPsrServerRequest();
58 58
 
59 59
 				try {
60
-					$psr     = $resource_server->validateAuthenticatedRequest( $psr_request );
61
-					$user_id = $manager->validateUserForRequest( $psr );
60
+					$psr     = $resource_server->validateAuthenticatedRequest($psr_request);
61
+					$user_id = $manager->validateUserForRequest($psr);
62 62
 
63
-					if ( $user_id ) {
64
-						$user = User::find( $user_id );
63
+					if ($user_id) {
64
+						$user = User::find($user_id);
65 65
 
66
-						$request->merge( array( 'user' => $user ) );
67
-						$request->merge( array( 'scopes' => $psr->getAttribute( 'oauth_scopes' ) ) );
66
+						$request->merge(array('user' => $user));
67
+						$request->merge(array('scopes' => $psr->getAttribute('oauth_scopes')));
68 68
 
69 69
 						$request->setUserResolver(
70
-							function () use ( $user ) {
70
+							function() use ($user) {
71 71
 								return $user;
72 72
 							}
73 73
 						);
74 74
 
75
-						return $next( $request );
75
+						return $next($request);
76 76
 					}
77
-				} catch ( OAuthServerException $e ) {
78
-					throw new \Exception( $e->getMessage() );
77
+				} catch (OAuthServerException $e) {
78
+					throw new \Exception($e->getMessage());
79 79
 
80 80
 				}
81 81
 
82
-				return $next( $request );
82
+				return $next($request);
83 83
 			}
84 84
 		}
85 85
 
86
-		if ( \is_user_logged_in() ) {
87
-			return $next( $request );
86
+		if (\is_user_logged_in()) {
87
+			return $next($request);
88 88
 		}
89 89
 
90
-		header( 'Location: ' . \get_site_url() . '/wp-admin' );
90
+		header('Location: '.\get_site_url().'/wp-admin');
91 91
 		die();
92 92
 	}
93 93
 }
Please login to merge, or discard this patch.
app/Http/Middleware/VerifyCsrfToken.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,19 +34,19 @@
 block discarded – undo
34 34
 	 *
35 35
 	 * @return mixed
36 36
 	 */
37
-	public function handle( Request $request, Closure $next ) {
38
-		$token  = $request->input( '_token' ) ?? $request->header( 'X-CSRF-TOKEN' );
37
+	public function handle(Request $request, Closure $next) {
38
+		$token  = $request->input('_token') ?? $request->header('X-CSRF-TOKEN');
39 39
 		$action = $request->wpb_nonce ?? 'wpb_nonce';
40 40
 
41
-		if ( ! wp_verify_nonce( $token, $action ) ) {
42
-			if ( $request->ajax() ) {
43
-				return wp_send_json( array( 'message' => 'CSRF Token mitchmatch' ), 403 );
41
+		if (!wp_verify_nonce($token, $action)) {
42
+			if ($request->ajax()) {
43
+				return wp_send_json(array('message' => 'CSRF Token mitchmatch'), 403);
44 44
 			}
45 45
 
46
-			throw new \Exception( 'CSRF Token mismatch' );
46
+			throw new \Exception('CSRF Token mismatch');
47 47
 
48 48
 		}
49 49
 
50
-		return $next( $request );
50
+		return $next($request);
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
app/Http/Middleware/Scope.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@
 block discarded – undo
40 40
 	 *
41 41
 	 * @return mixed
42 42
 	 */
43
-	public function handle( Request $request, Closure $next, ...$scopes ) {
44
-		foreach ( $scopes as $scope ) {
45
-			if ( ! in_array( $scope, $request->scopes ) ) {
46
-				wp_send_json( array( 'msg' => "You don't have enough permission" ), 400 );
43
+	public function handle(Request $request, Closure $next, ...$scopes) {
44
+		foreach ($scopes as $scope) {
45
+			if (!in_array($scope, $request->scopes)) {
46
+				wp_send_json(array('msg' => "You don't have enough permission"), 400);
47 47
 			}
48 48
 		}
49 49
 
50
-		return $next( $request );
50
+		return $next($request);
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
app/Commands/InstallComposer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@
 block discarded – undo
28 28
 	 * @since    1.0.0
29 29
 	 */
30 30
 	public function __construct() {
31
-		if ( ! file_exists( __DIR__ . '/../vendor/autoload.php' ) ) {
31
+		if (!file_exists(__DIR__.'/../vendor/autoload.php')) {
32 32
 
33
-			require_once __DIR__ . '/../vendor/autoload.php';
33
+			require_once __DIR__.'/../vendor/autoload.php';
34 34
 
35 35
 			$composer = 'composer';
36 36
 
37 37
 			try {
38
-				$process = \Symfony\Component\Process\Process::fromShellCommandline( $composer . ' install' );
38
+				$process = \Symfony\Component\Process\Process::fromShellCommandline($composer.' install');
39 39
 				$process->setEnv(
40 40
 					array(
41
-						'COMPOSER_HOME' => __DIR__ . '/../vendor/bin/composer',
41
+						'COMPOSER_HOME' => __DIR__.'/../vendor/bin/composer',
42 42
 					)
43 43
 				);
44
-				$process->setTimeout( null ); // Setting timeout to null to prevent installation from stopping at a certain point in time.
45
-				$process->setWorkingDirectory( __DIR__ )->mustRun();
46
-			} catch ( \Exception $ex ) {
44
+				$process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time.
45
+				$process->setWorkingDirectory(__DIR__)->mustRun();
46
+			} catch (\Exception $ex) {
47 47
 				echo $ex->getMessage();
48 48
 			}
49 49
 		}
Please login to merge, or discard this patch.
app/Exceptions/Handler.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @throws \Exception Throw the exception.
51 51
 	 */
52
-	public function report( Throwable $exception ) {
53
-		parent::report( $exception );
52
+	public function report(Throwable $exception) {
53
+		parent::report($exception);
54 54
 	}
55 55
 
56 56
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @throws \Throwable Throw the nexception.
64 64
 	 */
65
-	public function render( $request, Throwable $exception ) {
66
-		return parent::render( $request, $exception );
65
+	public function render($request, Throwable $exception) {
66
+		return parent::render($request, $exception);
67 67
 	}
68 68
 }
Please login to merge, or discard this patch.
src/Http/Kernel.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return void
92 92
 	 */
93
-	public function __construct( Container $app, Router $router ) {
93
+	public function __construct(Container $app, Router $router) {
94 94
 		$this->app    = $app;
95 95
 		$this->router = $router;
96 96
 
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return \Illuminate\Http\Response
108 108
 	 */
109
-	public function handle( $request ) {
109
+	public function handle($request) {
110 110
 		try {
111 111
 			$request->enableHttpMethodParameterOverride();
112
-			$response = $this->send_request_through_router( $request );
113
-		} catch ( Throwable $e ) {
114
-			$this->report_exception( $e );
115
-			$response = $this->render_exception( $request, $e );
116
-			throw new \Exception( $e, 1 );
112
+			$response = $this->send_request_through_router($request);
113
+		} catch (Throwable $e) {
114
+			$this->report_exception($e);
115
+			$response = $this->render_exception($request, $e);
116
+			throw new \Exception($e, 1);
117 117
 		}
118 118
 
119 119
 		$this->app['events']->dispatch(
120
-			new RequestHandled( $request, $response )
120
+			new RequestHandled($request, $response)
121 121
 		);
122 122
 
123 123
 		return $response;
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return \Illuminate\Http\Response
132 132
 	 */
133
-	protected function send_request_through_router( $request ) {
134
-		$this->app->instance( 'request', $request );
133
+	protected function send_request_through_router($request) {
134
+		$this->app->instance('request', $request);
135 135
 
136
-		Facade::clearResolvedInstance( 'request' );
136
+		Facade::clearResolvedInstance('request');
137 137
 
138 138
 		$this->bootstrap();
139 139
 
140
-		return ( new Pipeline( $this->app ) )
141
-					->send( $request )
142
-					->through( $this->middleware )
143
-					->then( $this->dispatch_to_router() );
140
+		return (new Pipeline($this->app))
141
+					->send($request)
142
+					->through($this->middleware)
143
+					->then($this->dispatch_to_router());
144 144
 	}
145 145
 
146 146
 	/**
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 	 * @return \Closure
157 157
 	 */
158 158
 	protected function dispatch_to_router() {
159
-		return function ( $request ) {
160
-			$this->app->instance( 'request', $request );
159
+		return function($request) {
160
+			$this->app->instance('request', $request);
161 161
 
162
-			return $this->router->dispatch( $request );
162
+			return $this->router->dispatch($request);
163 163
 		};
164 164
 	}
165 165
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return void
173 173
 	 */
174
-	public function terminate( $request, $response ) {
175
-		$this->terminate_middleware( $request, $response );
174
+	public function terminate($request, $response) {
175
+		$this->terminate_middleware($request, $response);
176 176
 
177 177
 		$this->app->terminate();
178 178
 	}
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return void
187 187
 	 */
188
-	protected function terminate_middleware( $request, $response ) {
188
+	protected function terminate_middleware($request, $response) {
189 189
 		$middlewares = $this->app->shouldSkipMiddleware() ? array() : array_merge(
190
-			$this->gather_route_middleware( $request ),
190
+			$this->gather_route_middleware($request),
191 191
 			$this->middleware
192 192
 		);
193 193
 
194
-		foreach ( $middlewares as $middleware ) {
195
-			if ( ! is_string( $middleware ) ) {
194
+		foreach ($middlewares as $middleware) {
195
+			if (!is_string($middleware)) {
196 196
 				continue;
197 197
 			}
198 198
 
199
-			list( $name ) = $this->parse_middleware( $middleware );
199
+			list($name) = $this->parse_middleware($middleware);
200 200
 
201
-			$instance = $this->app->make( $name );
201
+			$instance = $this->app->make($name);
202 202
 
203
-			if ( method_exists( $instance, 'terminate' ) ) {
204
-				$instance->terminate( $request, $response );
203
+			if (method_exists($instance, 'terminate')) {
204
+				$instance->terminate($request, $response);
205 205
 			}
206 206
 		}
207 207
 	}
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return array
215 215
 	 */
216
-	protected function gather_route_middleware( $request ) {
216
+	protected function gather_route_middleware($request) {
217 217
 		$route = $request->route();
218
-		if ( $route ) {
219
-			return $this->router->gatherRouteMiddleware( $route );
218
+		if ($route) {
219
+			return $this->router->gatherRouteMiddleware($route);
220 220
 		}
221 221
 
222 222
 		return array();
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return array
231 231
 	 */
232
-	protected function parse_middleware( $middleware ) {
232
+	protected function parse_middleware($middleware) {
233 233
 
234
-		list( $name, $parameters ) = array_pad( explode( ':', $middleware, 2 ), 2, array() );
234
+		list($name, $parameters) = array_pad(explode(':', $middleware, 2), 2, array());
235 235
 
236
-		if ( is_string( $parameters ) ) {
237
-			$parameters = explode( ',', $parameters );
236
+		if (is_string($parameters)) {
237
+			$parameters = explode(',', $parameters);
238 238
 		}
239 239
 
240
-		return array( $name, $parameters );
240
+		return array($name, $parameters);
241 241
 	}
242 242
 
243 243
 	/**
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool
249 249
 	 */
250
-	public function has_middleware( $middleware ) {
251
-		return in_array( $middleware, $this->middleware );
250
+	public function has_middleware($middleware) {
251
+		return in_array($middleware, $this->middleware);
252 252
 	}
253 253
 
254 254
 	/**
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return $this
260 260
 	 */
261
-	public function prepend_middleware( $middleware ) {
262
-		if ( array_search( $middleware, $this->middleware ) === false ) {
263
-			array_unshift( $this->middleware, $middleware );
261
+	public function prepend_middleware($middleware) {
262
+		if (array_search($middleware, $this->middleware) === false) {
263
+			array_unshift($this->middleware, $middleware);
264 264
 		}
265 265
 
266 266
 		return $this;
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return $this
275 275
 	 */
276
-	public function push_middleware( $middleware ) {
277
-		if ( array_search( $middleware, $this->middleware ) === false ) {
276
+	public function push_middleware($middleware) {
277
+		if (array_search($middleware, $this->middleware) === false) {
278 278
 			$this->middleware[] = $middleware;
279 279
 		}
280 280
 
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @return $this
293 293
 	 */
294
-	public function prepend_middleware_to_group( $group, $middleware ) {
295
-		if ( ! isset( $this->middleware_groups[ $group ] ) ) {
296
-			throw new InvalidArgumentException( "The [{$group}] middleware group has not been defined." );
294
+	public function prepend_middleware_to_group($group, $middleware) {
295
+		if (!isset($this->middleware_groups[$group])) {
296
+			throw new InvalidArgumentException("The [{$group}] middleware group has not been defined.");
297 297
 		}
298 298
 
299
-		if ( array_search( $middleware, $this->middleware_groups[ $group ] ) === false ) {
300
-			array_unshift( $this->middleware_groups[ $group ], $middleware );
299
+		if (array_search($middleware, $this->middleware_groups[$group]) === false) {
300
+			array_unshift($this->middleware_groups[$group], $middleware);
301 301
 		}
302 302
 
303 303
 		$this->sync_middleware_to_router();
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return $this
317 317
 	 */
318
-	public function append_middleware_to_group( $group, $middleware ) {
319
-		if ( ! isset( $this->middleware_groups[ $group ] ) ) {
320
-			throw new InvalidArgumentException( "The [{$group}] middleware group has not been defined." );
318
+	public function append_middleware_to_group($group, $middleware) {
319
+		if (!isset($this->middleware_groups[$group])) {
320
+			throw new InvalidArgumentException("The [{$group}] middleware group has not been defined.");
321 321
 		}
322 322
 
323
-		if ( array_search( $middleware, $this->middleware_groups[ $group ] ) === false ) {
324
-			$this->middleware_groups[ $group ][] = $middleware;
323
+		if (array_search($middleware, $this->middleware_groups[$group]) === false) {
324
+			$this->middleware_groups[$group][] = $middleware;
325 325
 		}
326 326
 
327 327
 		$this->sync_middleware_to_router();
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return $this
338 338
 	 */
339
-	public function prepend_to_middleware_priority( $middleware ) {
340
-		if ( ! in_array( $middleware, $this->middleware_priority ) ) {
341
-			array_unshift( $this->middleware_priority, $middleware );
339
+	public function prepend_to_middleware_priority($middleware) {
340
+		if (!in_array($middleware, $this->middleware_priority)) {
341
+			array_unshift($this->middleware_priority, $middleware);
342 342
 		}
343 343
 
344 344
 		$this->sync_middleware_to_router();
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @return $this
355 355
 	 */
356
-	public function append_to_middleware_priority( $middleware ) {
357
-		if ( ! in_array( $middleware, $this->middleware_priority ) ) {
356
+	public function append_to_middleware_priority($middleware) {
357
+		if (!in_array($middleware, $this->middleware_priority)) {
358 358
 			$this->middleware_priority[] = $middleware;
359 359
 		}
360 360
 
@@ -371,12 +371,12 @@  discard block
 block discarded – undo
371 371
 	protected function sync_middleware_to_router() {
372 372
 		$this->router->middlewarePriority = $this->middleware_priority;
373 373
 
374
-		foreach ( $this->middleware_groups as $key => $middleware ) {
375
-			$this->router->middlewareGroup( $key, $middleware );
374
+		foreach ($this->middleware_groups as $key => $middleware) {
375
+			$this->router->middlewareGroup($key, $middleware);
376 376
 		}
377 377
 
378
-		foreach ( $this->route_middleware as $key => $middleware ) {
379
-			$this->router->aliasMiddleware( $key, $middleware );
378
+		foreach ($this->route_middleware as $key => $middleware) {
379
+			$this->router->aliasMiddleware($key, $middleware);
380 380
 		}
381 381
 	}
382 382
 
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	 *
397 397
 	 * @return void
398 398
 	 */
399
-	protected function report_exception( Throwable $e ) {
400
-		$this->app[ ExceptionHandler::class ]->report( $e );
399
+	protected function report_exception(Throwable $e) {
400
+		$this->app[ExceptionHandler::class]->report($e);
401 401
 	}
402 402
 
403 403
 	/**
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @return \Symfony\Component\HttpFoundation\Response
410 410
 	 */
411
-	protected function render_exception( $request, Throwable $e ) {
412
-		return $this->app[ ExceptionHandler::class ]->render( $request, $e );
411
+	protected function render_exception($request, Throwable $e) {
412
+		return $this->app[ExceptionHandler::class]->render($request, $e);
413 413
 	}
414 414
 
415 415
 	/**
Please login to merge, or discard this patch.
src/Http/Events/RequestHandled.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 	 *
44 44
 	 * @return void
45 45
 	 */
46
-	public function __construct( $request, $response ) {
46
+	public function __construct($request, $response) {
47 47
 		$this->request  = $request;
48 48
 		$this->response = $response;
49 49
 	}
Please login to merge, or discard this patch.
src/Contracts/Http/Kernel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param  \Symfony\Component\HttpFoundation\Request $request The app http request.
35 35
 	 * @return \Symfony\Component\HttpFoundation\Response
36 36
 	 */
37
-	public function handle( $request);
37
+	public function handle($request);
38 38
 
39 39
 	/**
40 40
 	 * Perform any final actions for the request lifecycle.
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param  \Symfony\Component\HttpFoundation\Response $response The app http response.
44 44
 	 * @return void
45 45
 	 */
46
-	public function terminate( $request, $response);
46
+	public function terminate($request, $response);
47 47
 
48 48
 	/**
49 49
 	 * Get the Laravel application instance.
Please login to merge, or discard this patch.