Passed
Push — master ( c1cbd1...00d621 )
by Glynn
01:50
created
src/Route_Collection.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 class Route_Collection extends Collection {
20 20
 
21
-	protected const ALLOWED_ROUTE_TYPES = array( Route::class, Route_Group::class );
21
+	protected const ALLOWED_ROUTE_TYPES = array(Route::class, Route_Group::class);
22 22
 
23 23
 	/**
24 24
 	 * Overwrite this method in any extended classes, to modify the inital data.
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * @param array<int|string, mixed> $data
27 27
 	 * @return array<int|string, mixed>
28 28
 	 */
29
-	protected function map_construct( array $data ): array {
29
+	protected function map_construct(array $data): array {
30 30
 		return array_filter(
31 31
 			$data,
32
-			function( $datum ): bool {
32
+			function($datum): bool {
33 33
 				return in_array(
34
-					get_class( $datum ),
34
+					get_class($datum),
35 35
 					self::ALLOWED_ROUTE_TYPES,
36 36
 					true
37 37
 				);
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param Route|Route_Group $route
46 46
 	 * @return static
47 47
 	 */
48
-	public function add_route( $route ) {
49
-		$this->push( $route );
48
+	public function add_route($route) {
49
+		$this->push($route);
50 50
 		return $this;
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
src/Route_Factory.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	protected $namespace;
27 27
 
28
-	public function __construct( string $namespace ) {
28
+	public function __construct(string $namespace) {
29 29
 		$this->namespace = $namespace;
30 30
 	}
31 31
 
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * @param string $namespace
36 36
 	 * @return Route_Factory
37 37
 	 */
38
-	public static function for( string $namespace ): Route_Factory {
39
-		return new self( $namespace );
38
+	public static function for (string $namespace): Route_Factory {
39
+		return new self($namespace);
40 40
 	}
41 41
 
42 42
 	/**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @param callable $callback
48 48
 	 * @return Route
49 49
 	 */
50
-	protected function request( string $method, string $route, callable $callback ): Route {
51
-		$route = new Route( $method, $route );
50
+	protected function request(string $method, string $route, callable $callback): Route {
51
+		$route = new Route($method, $route);
52 52
 		return $route
53
-			->callback( $callback )
54
-			->namespace( $this->namespace );
53
+			->callback($callback)
54
+			->namespace($this->namespace);
55 55
 	}
56 56
 
57 57
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param callable $callback
62 62
 	 * @return Route
63 63
 	 */
64
-	public function get( string $route, callable $callback ): Route {
65
-		return $this->request( Route::GET, $route, $callback );
64
+	public function get(string $route, callable $callback): Route {
65
+		return $this->request(Route::GET, $route, $callback);
66 66
 	}
67 67
 
68 68
 	/**
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @param callable $callback
73 73
 	 * @return Route
74 74
 	 */
75
-	public function post( string $route, callable $callback ): Route {
76
-		return $this->request( Route::POST, $route, $callback );
75
+	public function post(string $route, callable $callback): Route {
76
+		return $this->request(Route::POST, $route, $callback);
77 77
 	}
78 78
 
79 79
 	/**
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * @param callable $callback
84 84
 	 * @return Route
85 85
 	 */
86
-	public function put( string $route, callable $callback ): Route {
87
-		return $this->request( Route::PUT, $route, $callback );
86
+	public function put(string $route, callable $callback): Route {
87
+		return $this->request(Route::PUT, $route, $callback);
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 * @param callable $callback
95 95
 	 * @return Route
96 96
 	 */
97
-	public function patch( string $route, callable $callback ): Route {
98
-		return $this->request( Route::PATCH, $route, $callback );
97
+	public function patch(string $route, callable $callback): Route {
98
+		return $this->request(Route::PATCH, $route, $callback);
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @param callable $callback
106 106
 	 * @return Route
107 107
 	 */
108
-	public function delete( string $route, callable $callback ): Route {
109
-		return $this->request( Route::DELETE, $route, $callback );
108
+	public function delete(string $route, callable $callback): Route {
109
+		return $this->request(Route::DELETE, $route, $callback);
110 110
 	}
111 111
 
112 112
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 	 * @param callable|null $config
117 117
 	 * @return Route_Group
118 118
 	 */
119
-	public function group_builder( string $route, ?callable $config ): Route_Group {
120
-		$group = new Route_Group( $this->namespace, $route );
119
+	public function group_builder(string $route, ?callable $config): Route_Group {
120
+		$group = new Route_Group($this->namespace, $route);
121 121
 
122 122
 		// Apply the callback.
123
-		if ( ! is_null( $config ) ) {
124
-			$config( $group );
123
+		if ( ! is_null($config)) {
124
+			$config($group);
125 125
 		}
126 126
 
127 127
 		return $group;
Please login to merge, or discard this patch.
src/Registration_Middleware/Route_Middleware.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/** @var Route_Manager */
28 28
 	protected $route_manager;
29 29
 
30
-	public function __construct( Route_Manager $route_manager ) {
30
+	public function __construct(Route_Manager $route_manager) {
31 31
 		$this->route_manager = $route_manager;
32 32
 	}
33 33
 
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 	 * @param object|Route_Controller $class
38 38
 	 * @return object
39 39
 	 */
40
-	public function process( $class ) {
40
+	public function process($class) {
41 41
 
42
-		if ( is_a( $class, Route_Controller::class ) ) {
43
-			$routes = $class->get_routes( new Route_Collection() );
42
+		if (is_a($class, Route_Controller::class)) {
43
+			$routes = $class->get_routes(new Route_Collection());
44 44
 			$routes->each(
45
-				function( Abstract_Route $route ) {
46
-					if ( is_a( $route, Route::class ) ) {
47
-						$this->route_manager->from_route( $route );
45
+				function(Abstract_Route $route) {
46
+					if (is_a($route, Route::class)) {
47
+						$this->route_manager->from_route($route);
48 48
 						return;
49 49
 					}
50 50
 
51
-					if ( is_a( $route, Route_Group::class ) ) {
52
-						$this->route_manager->from_group( $route );
51
+					if (is_a($route, Route_Group::class)) {
52
+						$this->route_manager->from_group($route);
53 53
 						return;
54 54
 					}
55 55
 				}
Please login to merge, or discard this patch.
src/Registration/Route_Manager.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/** @var WP_Rest_Registrar */
27 27
 	protected $registrar;
28 28
 
29
-	public function __construct( WP_Rest_Registrar $registrar, Hook_Loader $hook_loader ) {
29
+	public function __construct(WP_Rest_Registrar $registrar, Hook_Loader $hook_loader) {
30 30
 		$this->loader    = $hook_loader;
31 31
 		$this->registrar = $registrar;
32 32
 	}
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 	 * @param Route $route
38 38
 	 * @return self
39 39
 	 */
40
-	public function from_route( Route $route ): self {
40
+	public function from_route(Route $route): self {
41 41
 		$this->loader->action(
42 42
 			'rest_api_init',
43
-			$this->registrar->create_callback( $route )
43
+			$this->registrar->create_callback($route)
44 44
 		);
45 45
 
46 46
 		return $this;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @param \PinkCrab\Route\Route\Route_Group $group
53 53
 	 * @return self
54 54
 	 */
55
-	public function from_group( Route_Group $group ): self {
56
-		foreach ( $this->unpack_group( $group ) as $route ) {
57
-			$this->from_route( $route );
55
+	public function from_group(Route_Group $group): self {
56
+		foreach ($this->unpack_group($group) as $route) {
57
+			$this->from_route($route);
58 58
 		}
59 59
 
60 60
 		return $this;
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 	 * @return Route[]
68 68
 	 * @throws Route_Exception code 102
69 69
 	 */
70
-	protected function unpack_group( Route_Group $group ): array {
70
+	protected function unpack_group(Route_Group $group): array {
71 71
 
72 72
 		$routes = array();
73 73
 		// Loop through each group
74
-		foreach ( $group->get_rest_routes() as $method => $route ) {
75
-			$populated_route = $this->create_base_route_from_group( $method, $group );
74
+		foreach ($group->get_rest_routes() as $method => $route) {
75
+			$populated_route = $this->create_base_route_from_group($method, $group);
76 76
 
77 77
 			// Replace args if set.
78
-			foreach ( $route->get_arguments() as $key => $argument ) {
79
-				$populated_route->argument( $argument );
78
+			foreach ($route->get_arguments() as $key => $argument) {
79
+				$populated_route->argument($argument);
80 80
 			}
81 81
 
82 82
 			// Extends any group based authentication with a route based.
83
-			foreach ( $route->get_authentication() as $key => $auth_callback ) {
84
-				$populated_route->authentication( $auth_callback );
83
+			foreach ($route->get_authentication() as $key => $auth_callback) {
84
+				$populated_route->authentication($auth_callback);
85 85
 			}
86 86
 
87 87
 			// If we have no callback defined for route, throw.
88
-			if ( is_null( $route->get_callback() ) ) {
89
-				throw Route_Exception::callback_not_defined( $route );
88
+			if (is_null($route->get_callback())) {
89
+				throw Route_Exception::callback_not_defined($route);
90 90
 			}
91 91
 
92
-			$populated_route->callback( $route->get_callback() );
92
+			$populated_route->callback($route->get_callback());
93 93
 
94
-			$routes[ $method ] = $populated_route;
94
+			$routes[$method] = $populated_route;
95 95
 		}
96 96
 		return $routes;
97 97
 	}
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	 * @param Route_Group $group
106 106
 	 * @return Route
107 107
 	 */
108
-	protected function create_base_route_from_group( string $method, Route_Group $group ): Route {
109
-		$route = new Route( \strtoupper( $method ), $group->get_route() );
110
-		$route->namespace( $group->get_namespace() );
108
+	protected function create_base_route_from_group(string $method, Route_Group $group): Route {
109
+		$route = new Route(\strtoupper($method), $group->get_route());
110
+		$route->namespace($group->get_namespace());
111 111
 
112
-		foreach ( $group->get_authentication() as $auth_callback ) {
113
-			$route->authentication( $auth_callback );
112
+		foreach ($group->get_authentication() as $auth_callback) {
113
+			$route->authentication($auth_callback);
114 114
 		}
115 115
 
116
-		foreach ( $group->get_arguments() as $argument ) {
117
-			$route->argument( $argument );
116
+		foreach ($group->get_arguments() as $argument) {
117
+			$route->argument($argument);
118 118
 		}
119 119
 
120 120
 		return $route;
Please login to merge, or discard this patch.
src/Route/Abstract_Route.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 * @param Argument $argument
56 56
 	 * @return static
57 57
 	 */
58
-	public function argument( Argument $argument ) {
59
-		$this->arguments[ $argument->get_key() ] = $argument;
58
+	public function argument(Argument $argument) {
59
+		$this->arguments[$argument->get_key()] = $argument;
60 60
 		return $this;
61 61
 	}
62 62
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @param string $key
67 67
 	 * @return bool
68 68
 	 */
69
-	public function has_argument( string $key ): bool {
70
-		return \array_key_exists( $key, $this->arguments );
69
+	public function has_argument(string $key): bool {
70
+		return \array_key_exists($key, $this->arguments);
71 71
 	}
72 72
 
73 73
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param callable(\WP_REST_Request): bool $auth_callback
77 77
 	 * @return static
78 78
 	 */
79
-	public function authentication( callable $auth_callback ) {
79
+	public function authentication(callable $auth_callback) {
80 80
 		$this->authentication[] = $auth_callback;
81 81
 		return $this;
82 82
 	}
Please login to merge, or discard this patch.
src/Route/Route_Group.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	protected $route;
37 37
 
38
-	public function __construct( string $namespace, string $route ) {
38
+	public function __construct(string $namespace, string $route) {
39 39
 		$this->route         = $route;
40 40
 		$this->namespace     = $namespace;
41
-		$this->route_factory = new Route_Factory( $namespace );
41
+		$this->route_factory = new Route_Factory($namespace);
42 42
 	}
43 43
 
44 44
 	/**
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 * @param callable $callable
57 57
 	 * @return Route
58 58
 	 */
59
-	public function get( callable $callable ): Route {
60
-		$route = $this->route_factory->get( $this->route, $callable );
61
-		$route->namespace( $this->namespace );
62
-		$this->routes[ Route::GET ] = $route;
59
+	public function get(callable $callable): Route {
60
+		$route = $this->route_factory->get($this->route, $callable);
61
+		$route->namespace($this->namespace);
62
+		$this->routes[Route::GET] = $route;
63 63
 		return $route;
64 64
 	}
65 65
 
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 * @param callable $callable
70 70
 	 * @return Route
71 71
 	 */
72
-	public function post( callable $callable ): Route {
73
-		$route = $this->route_factory->post( $this->route, $callable );
74
-		$route->namespace( $this->namespace );
75
-		$this->routes[ Route::POST ] = $route;
72
+	public function post(callable $callable): Route {
73
+		$route = $this->route_factory->post($this->route, $callable);
74
+		$route->namespace($this->namespace);
75
+		$this->routes[Route::POST] = $route;
76 76
 		return $route;
77 77
 	}
78 78
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @param callable $callable
83 83
 	 * @return Route
84 84
 	 */
85
-	public function put( callable $callable ): Route {
86
-		$route = $this->route_factory->put( $this->route, $callable );
87
-		$route->namespace( $this->namespace );
88
-		$this->routes[ Route::PUT ] = $route;
85
+	public function put(callable $callable): Route {
86
+		$route = $this->route_factory->put($this->route, $callable);
87
+		$route->namespace($this->namespace);
88
+		$this->routes[Route::PUT] = $route;
89 89
 		return $route;
90 90
 	}
91 91
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 * @param callable $callable
96 96
 	 * @return Route
97 97
 	 */
98
-	public function patch( callable $callable ): Route {
99
-		$route = $this->route_factory->patch( $this->route, $callable );
100
-		$route->namespace( $this->namespace );
101
-		$this->routes[ Route::PATCH ] = $route;
98
+	public function patch(callable $callable): Route {
99
+		$route = $this->route_factory->patch($this->route, $callable);
100
+		$route->namespace($this->namespace);
101
+		$this->routes[Route::PATCH] = $route;
102 102
 		return $route;
103 103
 	}
104 104
 
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 * @param callable $callable
109 109
 	 * @return Route
110 110
 	 */
111
-	public function delete( callable $callable ): Route {
112
-		$route = $this->route_factory->delete( $this->route, $callable );
113
-		$route->namespace( $this->namespace );
114
-		$this->routes[ Route::DELETE ] = $route;
111
+	public function delete(callable $callable): Route {
112
+		$route = $this->route_factory->delete($this->route, $callable);
113
+		$route->namespace($this->namespace);
114
+		$this->routes[Route::DELETE] = $route;
115 115
 		return $route;
116 116
 	}
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @deprecated 0.0.2 This is not really used and should be removed in a future version.
123 123
 	 * @return self
124 124
 	 */
125
-	public function add_rest_route( Route $route ): self {
126
-		$this->routes[ $route->get_method() ] = $route;
125
+	public function add_rest_route(Route $route): self {
126
+		$this->routes[$route->get_method()] = $route;
127 127
 		return $this;
128 128
 	}
129 129
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @param string $method
143 143
 	 * @return bool
144 144
 	 */
145
-	public function method_exists( string $method ): bool {
146
-		return array_key_exists( \strtoupper( $method ), $this->routes );
145
+	public function method_exists(string $method): bool {
146
+		return array_key_exists(\strtoupper($method), $this->routes);
147 147
 	}
148 148
 
149 149
 	/**
@@ -152,6 +152,6 @@  discard block
 block discarded – undo
152 152
 	 * @return bool
153 153
 	 */
154 154
 	public function has_routes(): bool {
155
-		return ! empty( $this->routes );
155
+		return ! empty($this->routes);
156 156
 	}
157 157
 }
Please login to merge, or discard this patch.
src/Route/Route.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	protected $callback = null;
37 37
 
38 38
 
39
-	public function __construct( string $method, string $route ) {
39
+	public function __construct(string $method, string $route) {
40 40
 		$this->method = $method;
41
-		$this->route  = $this->format_route( $route );
41
+		$this->route  = $this->format_route($route);
42 42
 	}
43 43
 
44 44
 	/**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 	 * @param string $route
48 48
 	 * @return string
49 49
 	 */
50
-	protected function format_route( string $route ): string {
51
-		$route = $this->translate_arguments( $route );
52
-		return '/' . ltrim( $route, '/\\' );
50
+	protected function format_route(string $route): string {
51
+		$route = $this->translate_arguments($route);
52
+		return '/'.ltrim($route, '/\\');
53 53
 	}
54 54
 
55 55
 	/**
@@ -59,27 +59,27 @@  discard block
 block discarded – undo
59 59
 	 * @param string $route
60 60
 	 * @return string
61 61
 	 */
62
-	protected function translate_arguments( string $route ): string {
63
-		if ( preg_match( '/[^-:\/_{}()a-zA-Z\d]/', $route ) ) {
62
+	protected function translate_arguments(string $route): string {
63
+		if (preg_match('/[^-:\/_{}()a-zA-Z\d]/', $route)) {
64 64
 			return $route;
65 65
 		}
66 66
 
67 67
 		// Create capture group for ":parameter"
68 68
 		$allowed_chars = '[\@a-zA-Z0-9&.?:-_=#]*';
69 69
 		$route         = preg_replace(
70
-			'/:(' . $allowed_chars . ')/',
71
-			'(?<$1>' . $allowed_chars . ')',
70
+			'/:('.$allowed_chars.')/',
71
+			'(?<$1>'.$allowed_chars.')',
72 72
 			$route
73 73
 		);
74 74
 
75 75
 		// Create capture group for '{parameter}'
76 76
 		$route = preg_replace(
77
-			'/{(' . $allowed_chars . ')}/',
78
-			'(?<$1>' . $allowed_chars . ')',
79
-			is_string( $route ) ? $route : ''
77
+			'/{('.$allowed_chars.')}/',
78
+			'(?<$1>'.$allowed_chars.')',
79
+			is_string($route) ? $route : ''
80 80
 		);
81 81
 
82
-		return is_string( $route ) ? $route : '';
82
+		return is_string($route) ? $route : '';
83 83
 	}
84 84
 
85 85
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return self
100 100
 	 */
101
-	public function callback( callable $callback ): self {
101
+	public function callback(callable $callback): self {
102 102
 		$this->callback = $callback;
103 103
 		return $this;
104 104
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param string $namespace
128 128
 	 * @return static
129 129
 	 */
130
-	public function namespace( string $namespace ) {
130
+	public function namespace(string $namespace) {
131 131
 		$this->namespace = $namespace;
132 132
 		return $this;
133 133
 	}
@@ -138,27 +138,27 @@  discard block
 block discarded – undo
138 138
 	 * @param string $method
139 139
 	 * @return self
140 140
 	 */
141
-	public function with_method( string $method ): self {
142
-		$clone = new self( $method, $this->get_route() );
141
+	public function with_method(string $method): self {
142
+		$clone = new self($method, $this->get_route());
143 143
 		// Arguments
144
-		if ( ! empty( $this->arguments ) ) {
145
-			foreach ( $this->arguments as $argument ) {
146
-				$clone->argument( $argument );
144
+		if ( ! empty($this->arguments)) {
145
+			foreach ($this->arguments as $argument) {
146
+				$clone->argument($argument);
147 147
 			}
148 148
 		}
149 149
 		// Authentication
150
-		if ( ! empty( $this->authentication ) ) {
151
-			foreach ( $this->authentication as $authentication ) {
152
-				$clone->authentication( $authentication );
150
+		if ( ! empty($this->authentication)) {
151
+			foreach ($this->authentication as $authentication) {
152
+				$clone->authentication($authentication);
153 153
 			}
154 154
 		}
155 155
 		// Callback
156
-		if ( ! empty( $this->callback ) ) {
157
-			$clone->callback( $this->callback );
156
+		if ( ! empty($this->callback)) {
157
+			$clone->callback($this->callback);
158 158
 		}
159 159
 		// Namespace
160
-		if ( ! empty( $this->namespace ) ) {
161
-			$clone->namespace( $this->namespace );
160
+		if ( ! empty($this->namespace)) {
161
+			$clone->namespace($this->namespace);
162 162
 		}
163 163
 
164 164
 		return $clone;
Please login to merge, or discard this patch.
src/Route_Exception.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	 * @return self
25 25
 	 * @code 101
26 26
 	 */
27
-	public static function namespace_not_defined( string $route ): self {
27
+	public static function namespace_not_defined(string $route): self {
28 28
 		return new self(
29
-			sprintf( 'Namespace not defined in %s', $route ),
29
+			sprintf('Namespace not defined in %s', $route),
30 30
 			101
31 31
 		);
32 32
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @return self
39 39
 	 * @code 102
40 40
 	 */
41
-	public static function callback_not_defined( Route $route ): self {
41
+	public static function callback_not_defined(Route $route): self {
42 42
 		// Set the namespace if exists.
43 43
 		$namespace = '' !== $route->get_namespace()
44 44
 				? $route->get_namespace()
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 		return new self(
48 48
 			sprintf(
49 49
 				'Callback not defined for [%s] %s%s',
50
-				strtoupper( $route->get_method() ),
51
-				strtoupper( $namespace ),
52
-				strtoupper( $route->get_route() )
50
+				strtoupper($route->get_method()),
51
+				strtoupper($namespace),
52
+				strtoupper($route->get_route())
53 53
 			),
54 54
 			102
55 55
 		);
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 * @param Route $route
62 62
 	 * @return self
63 63
 	 */
64
-	public static function invalid_http_method( Route $route ): self {
64
+	public static function invalid_http_method(Route $route): self {
65 65
 		return new self(
66 66
 			sprintf(
67 67
 				'%s is a none supported HTTP Mehtod.',
68
-				strtoupper( $route->get_method() )
68
+				strtoupper($route->get_method())
69 69
 			),
70 70
 			103
71 71
 		);
Please login to merge, or discard this patch.
src/Registration_Middleware/Route_Controller.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * @throws Route_Exception (code 101)
36 36
 	 */
37 37
 	private function get_namespace(): string {
38
-		if ( ! is_string( $this->namespace ) || mb_strlen( $this->namespace ) === 0 ) {
39
-			throw Route_Exception::namespace_not_defined( get_class( $this ) );
38
+		if ( ! is_string($this->namespace) || mb_strlen($this->namespace) === 0) {
39
+			throw Route_Exception::namespace_not_defined(get_class($this));
40 40
 		}
41 41
 
42 42
 		return $this->namespace;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @throws Route_Exception (code 101)
50 50
 	 */
51 51
 	private function get_factory(): Route_Factory {
52
-		return Route_Factory::for( $this->get_namespace() );
52
+		return Route_Factory::for ($this->get_namespace());
53 53
 	}
54 54
 
55 55
 	/**
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 * @param Route_Collection $collection
59 59
 	 * @return Route_Collection
60 60
 	 */
61
-	final public function get_routes( Route_Collection $collection ): Route_Collection {
62
-		$routes = $this->define_routes( $this->get_factory() );
63
-		foreach ( $routes as $route ) {
64
-			$collection->add_route( $route );
61
+	final public function get_routes(Route_Collection $collection): Route_Collection {
62
+		$routes = $this->define_routes($this->get_factory());
63
+		foreach ($routes as $route) {
64
+			$collection->add_route($route);
65 65
 		}
66 66
 
67 67
 		return $collection;
@@ -73,6 +73,6 @@  discard block
 block discarded – undo
73 73
 	 * @param Route_Factory $factory
74 74
 	 * @return array<Route|Route_Group>
75 75
 	 */
76
-	abstract protected function define_routes( Route_Factory $factory): array;
76
+	abstract protected function define_routes(Route_Factory $factory): array;
77 77
 
78 78
 }
Please login to merge, or discard this patch.