@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware |
23 | 23 | * @return object |
24 | 24 | */ |
25 | - public function addMiddleware( $middleware ); |
|
25 | + public function addMiddleware($middleware); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Alias for addMiddleware |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware |
31 | 31 | * @return object |
32 | 32 | */ |
33 | - public function add( $middleware ); |
|
33 | + public function add($middleware); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Execute an array of middleware recursively (last in, first out) |
@@ -40,5 +40,5 @@ discard block |
||
40 | 40 | * @param Closure $next |
41 | 41 | * @return ResponseInterface |
42 | 42 | */ |
43 | - public function executeMiddleware( $middleware, $request, Closure $next ); |
|
43 | + public function executeMiddleware($middleware, $request, Closure $next); |
|
44 | 44 | } |
@@ -14,14 +14,14 @@ |
||
14 | 14 | /** |
15 | 15 | * {@inheritDoc} |
16 | 16 | */ |
17 | - public function handle( $request, Closure $next ) { |
|
18 | - $response = $next( $request ); |
|
17 | + public function handle($request, Closure $next) { |
|
18 | + $response = $next($request); |
|
19 | 19 | |
20 | - if ( Flash::enabled() ) { |
|
21 | - Flash::clear( OldInputService::getFlashKey() ); |
|
20 | + if (Flash::enabled()) { |
|
21 | + Flash::clear(OldInputService::getFlashKey()); |
|
22 | 22 | |
23 | - if ( $request->getMethod() === 'POST' ) { |
|
24 | - Flash::add( OldInputService::getFlashKey(), $request->post() ); |
|
23 | + if ($request->getMethod() === 'POST') { |
|
24 | + Flash::add(OldInputService::getFlashKey(), $request->post()); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param RouteInterface $route |
31 | 31 | * @return RouteInterface |
32 | 32 | */ |
33 | - public function addRoute( $route ) { |
|
33 | + public function addRoute($route) { |
|
34 | 34 | $this->routes[] = $route; |
35 | 35 | return $route; |
36 | 36 | } |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @param string|Closure $handler |
44 | 44 | * @return RouteInterface |
45 | 45 | */ |
46 | - public function route( $methods, $target, $handler ) { |
|
47 | - $route = new Route( $methods, $target, $handler ); |
|
48 | - return $this->addRoute( $route ); |
|
46 | + public function route($methods, $target, $handler) { |
|
47 | + $route = new Route($methods, $target, $handler); |
|
48 | + return $this->addRoute($route); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param Closure $callable |
56 | 56 | * @return RouteInterface |
57 | 57 | */ |
58 | - public function group( $target, Closure $callable ) { |
|
59 | - $routeGroup = new RouteGroup( $target, $callable ); |
|
60 | - return $this->addRoute( $routeGroup ); |
|
58 | + public function group($target, Closure $callable) { |
|
59 | + $routeGroup = new RouteGroup($target, $callable); |
|
60 | + return $this->addRoute($routeGroup); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @param string|Closure $handler |
68 | 68 | * @return RouteInterface |
69 | 69 | */ |
70 | - public function get( $target, $handler ) { |
|
71 | - return $this->route( ['GET', 'HEAD'], $target, $handler ); |
|
70 | + public function get($target, $handler) { |
|
71 | + return $this->route(['GET', 'HEAD'], $target, $handler); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param string|Closure $handler |
79 | 79 | * @return RouteInterface |
80 | 80 | */ |
81 | - public function post( $target, $handler ) { |
|
82 | - return $this->route( ['POST'], $target, $handler ); |
|
81 | + public function post($target, $handler) { |
|
82 | + return $this->route(['POST'], $target, $handler); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param string|Closure $handler |
90 | 90 | * @return RouteInterface |
91 | 91 | */ |
92 | - public function put( $target, $handler ) { |
|
93 | - return $this->route( ['PUT'], $target, $handler ); |
|
92 | + public function put($target, $handler) { |
|
93 | + return $this->route(['PUT'], $target, $handler); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param string|Closure $handler |
101 | 101 | * @return RouteInterface |
102 | 102 | */ |
103 | - public function patch( $target, $handler ) { |
|
104 | - return $this->route( ['PATCH'], $target, $handler ); |
|
103 | + public function patch($target, $handler) { |
|
104 | + return $this->route(['PATCH'], $target, $handler); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param string|Closure $handler |
112 | 112 | * @return RouteInterface |
113 | 113 | */ |
114 | - public function delete( $target, $handler ) { |
|
115 | - return $this->route( ['DELETE'], $target, $handler ); |
|
114 | + public function delete($target, $handler) { |
|
115 | + return $this->route(['DELETE'], $target, $handler); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string|Closure $handler |
123 | 123 | * @return RouteInterface |
124 | 124 | */ |
125 | - public function options( $target, $handler ) { |
|
126 | - return $this->route( ['OPTIONS'], $target, $handler ); |
|
125 | + public function options($target, $handler) { |
|
126 | + return $this->route(['OPTIONS'], $target, $handler); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param string|Closure $handler |
134 | 134 | * @return RouteInterface |
135 | 135 | */ |
136 | - public function any( $target, $handler ) { |
|
137 | - return $this->route( ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $target, $handler ); |
|
136 | + public function any($target, $handler) { |
|
137 | + return $this->route(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $target, $handler); |
|
138 | 138 | } |
139 | 139 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | * @param callable $callable |
27 | 27 | * @param any ...$arguments |
28 | 28 | */ |
29 | - public function __construct( $callable ) { |
|
29 | + public function __construct($callable) { |
|
30 | 30 | $this->callable = $callable; |
31 | - $this->arguments = array_slice( func_get_args(), 1 ); |
|
31 | + $this->arguments = array_slice(func_get_args(), 1); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * {@inheritDoc} |
36 | 36 | */ |
37 | 37 | public function satisfied() { |
38 | - return call_user_func_array( $this->callable, $this->arguments ); |
|
38 | + return call_user_func_array($this->callable, $this->arguments); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -26,18 +26,18 @@ |
||
26 | 26 | * @param string $post_template |
27 | 27 | * @param string|string[] $post_types |
28 | 28 | */ |
29 | - public function __construct( $post_template, $post_types = [] ) { |
|
29 | + public function __construct($post_template, $post_types = []) { |
|
30 | 30 | $this->post_template = $post_template; |
31 | - $this->post_types = is_array( $post_types ) ? $post_types : [$post_types]; |
|
31 | + $this->post_types = is_array($post_types) ? $post_types : [$post_types]; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * {@inheritDoc} |
36 | 36 | */ |
37 | 37 | public function satisfied() { |
38 | - $template = get_post_meta( get_the_ID(), '_wp_page_template', true ); |
|
38 | + $template = get_post_meta(get_the_ID(), '_wp_page_template', true); |
|
39 | 39 | $template = $template ? $template : 'default'; |
40 | - return ( is_singular( $this->post_types ) && $this->post_template === $template ); |
|
40 | + return (is_singular($this->post_types) && $this->post_template === $template); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * |
19 | 19 | * @param string $post_type |
20 | 20 | */ |
21 | - public function __construct( $post_type ) { |
|
21 | + public function __construct($post_type) { |
|
22 | 22 | $this->post_type = $post_type; |
23 | 23 | } |
24 | 24 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * |
19 | 19 | * @param string $post_id |
20 | 20 | */ |
21 | - public function __construct( $post_id ) { |
|
21 | + public function __construct($post_id) { |
|
22 | 22 | $this->post_id = $post_id; |
23 | 23 | } |
24 | 24 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @param string $post_slug |
20 | 20 | */ |
21 | - public function __construct( $post_slug ) { |
|
21 | + public function __construct($post_slug) { |
|
22 | 22 | $this->post_slug = $post_slug; |
23 | 23 | } |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function satisfied() { |
29 | 29 | $post = get_post(); |
30 | - return ( $post && $this->post_slug === $post->post_name ); |
|
30 | + return ($post && $this->post_slug === $post->post_name); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @return null |
21 | 21 | */ |
22 | 22 | public function boot() { |
23 | - add_action( 'template_include', array( $this, 'execute' ), 1000 ); |
|
23 | + add_action('template_include', array($this, 'execute'), 1000); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param string $template |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function execute( $template ) { |
|
32 | + public function execute($template) { |
|
33 | 33 | $routes = $this->getRoutes(); |
34 | - $global_middleware = Framework::resolve( 'framework.global_middleware' ); |
|
34 | + $global_middleware = Framework::resolve('framework.global_middleware'); |
|
35 | 35 | |
36 | - foreach ( $routes as $route ) { |
|
37 | - $route->addMiddleware( $global_middleware ); |
|
36 | + foreach ($routes as $route) { |
|
37 | + $route->addMiddleware($global_middleware); |
|
38 | 38 | } |
39 | 39 | |
40 | - foreach ( $routes as $route ) { |
|
41 | - if ( $route->satisfied() ) { |
|
42 | - return $this->handle( $route ); |
|
40 | + foreach ($routes as $route) { |
|
41 | + if ($route->satisfied()) { |
|
42 | + return $this->handle($route); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | * @param RouteInterface $route |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - protected function handle( RouteInterface $route ) { |
|
55 | + protected function handle(RouteInterface $route) { |
|
56 | 56 | $request = Request::fromGlobals(); |
57 | - $response = $route->handle( $request ); |
|
57 | + $response = $route->handle($request); |
|
58 | 58 | |
59 | - if ( ! is_a( $response, ResponseInterface::class ) ) { |
|
60 | - if ( Framework::debugging() ) { |
|
61 | - throw new Exception( 'Response returned by controller is not valid (expectected ' . ResponseInterface::class . '; received ' . gettype( $response ) . ').' ); |
|
59 | + if ( ! is_a($response, ResponseInterface::class)) { |
|
60 | + if (Framework::debugging()) { |
|
61 | + throw new Exception('Response returned by controller is not valid (expectected ' . ResponseInterface::class . '; received ' . gettype($response) . ').'); |
|
62 | 62 | } |
63 | - $response = FrameworkResponse::error( FrameworkResponse::response(), 500 ); |
|
63 | + $response = FrameworkResponse::error(FrameworkResponse::response(), 500); |
|
64 | 64 | } |
65 | 65 | |
66 | - add_filter( 'carbon_framework_response', function() use ( $response ) { |
|
66 | + add_filter('carbon_framework_response', function() use ($response) { |
|
67 | 67 | return $response; |
68 | 68 | } ); |
69 | 69 |