Passed
Pull Request — master (#45)
by Glynn
08:31
created
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 ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.namespaceFound
130
+	public function namespace(string $namespace) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.namespaceFound
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.