Passed
Branch master (158c7e)
by htmlBurger
02:35
created
src/Templating/EngineInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
 	 * @param  array  $context
14 14
 	 * @return string
15 15
 	 */
16
-	public function render( $file, $context );
16
+	public function render($file, $context);
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
src/Templating/Php.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
 	/**
10 10
 	 * {@inheritDoc}
11 11
 	 */
12
-	public function render( $file, $context ) {
12
+	public function render($file, $context) {
13 13
 		$__template = $file;
14 14
 		$__context = $context;
15
-		$renderer = function() use ( $__template, $__context ) {
15
+		$renderer = function() use ($__template, $__context) {
16 16
 			ob_start();
17
-			extract( $__context );
18
-			include( $__template );
17
+			extract($__context);
18
+			include($__template);
19 19
 			return ob_get_clean();
20 20
 		};
21 21
 		return $renderer();
Please login to merge, or discard this patch.
src/Response.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	 * @param  ResponseInterface $response
27 27
 	 * @return null
28 28
 	 */
29
-	public static function respond( ResponseInterface $response ) {
29
+	public static function respond(ResponseInterface $response) {
30 30
 		// Send response
31
-		if (!headers_sent()) {
31
+		if ( ! headers_sent()) {
32 32
 			// Status
33 33
 			header(sprintf(
34 34
 				'HTTP/%s %s %s',
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		}
51 51
 		$chunkSize = 4096;
52 52
 		$contentLength = $response->getHeaderLine('Content-Length');
53
-		if (!$contentLength) {
53
+		if ( ! $contentLength) {
54 54
 			$contentLength = $body->getSize();
55 55
 		}
56 56
 		if (isset($contentLength)) {
57 57
 			$amountToRead = $contentLength;
58
-			while ($amountToRead > 0 && !$body->eof()) {
58
+			while ($amountToRead > 0 && ! $body->eof()) {
59 59
 				$data = $body->read(min($chunkSize, $amountToRead));
60 60
 				echo $data;
61 61
 				$amountToRead -= strlen($data);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 				}
65 65
 			}
66 66
 		} else {
67
-			while (!$body->eof()) {
67
+			while ( ! $body->eof()) {
68 68
 				echo $body->read($chunkSize);
69 69
 				if (connection_status() != CONNECTION_NORMAL) {
70 70
 					break;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @param  string       $output
81 81
 	 * @return Psr7Response
82 82
 	 */
83
-	public static function output( Psr7Response $response, $output ) {
84
-		$response = $response->withBody( Psr7\stream_for( $output ) );
83
+	public static function output(Psr7Response $response, $output) {
84
+		$response = $response->withBody(Psr7\stream_for($output));
85 85
 		return $response;
86 86
 	}
87 87
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @param  array           $context
94 94
 	 * @return Psr7Response
95 95
 	 */
96
-	public static function template( Psr7Response $response, $templates, $context = array() ) {
97
-		$templates = is_array( $templates ) ? $templates : [$templates];
98
-		$template = locate_template( $templates, false );
96
+	public static function template(Psr7Response $response, $templates, $context = array()) {
97
+		$templates = is_array($templates) ? $templates : [$templates];
98
+		$template = locate_template($templates, false);
99 99
 
100
-		$engine = Framework::resolve( 'framework.templating.engine' );
101
-		$html = $engine->render( $template, $context );
100
+		$engine = Framework::resolve('framework.templating.engine');
101
+		$html = $engine->render($template, $context);
102 102
 
103
-		$response = $response->withHeader( 'Content-Type', 'text/html' );
104
-		$response = $response->withBody( Psr7\stream_for( $html ) );
103
+		$response = $response->withHeader('Content-Type', 'text/html');
104
+		$response = $response->withBody(Psr7\stream_for($html));
105 105
 		return $response;
106 106
 	}
107 107
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 * @param  array        $data
113 113
 	 * @return Psr7Response
114 114
 	 */
115
-	public static function json( Psr7Response $response, $data ) {
116
-		$response = $response->withHeader( 'Content-Type', 'application/json' );
117
-		$response = $response->withBody( Psr7\stream_for( wp_json_encode( $data ) ) );
115
+	public static function json(Psr7Response $response, $data) {
116
+		$response = $response->withHeader('Content-Type', 'application/json');
117
+		$response = $response->withBody(Psr7\stream_for(wp_json_encode($data)));
118 118
 		return $response;
119 119
 	}
120 120
 
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 * @param  integer      $status
127 127
 	 * @return Psr7Response
128 128
 	 */
129
-	public static function redirect( Psr7Response $response, $url, $status = 302 ) {
130
-		$response = $response->withStatus( $status );
131
-		$response = $response->withHeader( 'Location', $url );
129
+	public static function redirect(Psr7Response $response, $url, $status = 302) {
130
+		$response = $response->withStatus($status);
131
+		$response = $response->withHeader('Location', $url);
132 132
 		return $response;
133 133
 	}
134 134
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 	 * @param  integer      $status
140 140
 	 * @return Psr7Response
141 141
 	 */
142
-	public static function error( Psr7Response $response, $status ) {
142
+	public static function error(Psr7Response $response, $status) {
143 143
 		global $wp_query;
144
-		if ( $status === 404 ) {
144
+		if ($status === 404) {
145 145
 			$wp_query->set_404();
146 146
 		}
147 147
 
148
-		$response = $response->withStatus( $status );
149
-		return static::template( $response, array( $status . '.php', 'index.php' ) );
148
+		$response = $response->withStatus($status);
149
+		return static::template($response, array($status . '.php', 'index.php'));
150 150
 	}
151 151
 }
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return Request
57 57
 	 */
58 58
 	public static function fromGlobals() {
59
-		return new static( stripslashes_deep( $_GET ), stripslashes_deep( $_POST ), $_COOKIE, $_FILES, $_SERVER, getallheaders() );
59
+		return new static(stripslashes_deep($_GET), stripslashes_deep($_POST), $_COOKIE, $_FILES, $_SERVER, getallheaders());
60 60
 	}
61 61
 
62 62
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @param array $server
70 70
 	 * @param array $headers
71 71
 	 */
72
-	public function __construct( $get, $post, $cookie, $files, $server, $headers ) {
72
+	public function __construct($get, $post, $cookie, $files, $server, $headers) {
73 73
 		$this->get = $get;
74 74
 		$this->post = $post;
75 75
 		$this->cookie = $cookie;
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	 * @return string
85 85
 	 */
86 86
 	public function getMethod() {
87
-		$method = Arr::get( $this->server, 'REQUEST_METHOD', 'GET' );
87
+		$method = Arr::get($this->server, 'REQUEST_METHOD', 'GET');
88 88
 		
89
-		$override = Arr::get( $this->headers, 'X-HTTP-METHOD-OVERRIDE' );
90
-		if ( $method === 'POST' && $override ) {
89
+		$override = Arr::get($this->headers, 'X-HTTP-METHOD-OVERRIDE');
90
+		if ($method === 'POST' && $override) {
91 91
 			$method = $override;
92 92
 		}
93 93
 
94
-		return strtoupper( $method );
94
+		return strtoupper($method);
95 95
 	}
96 96
 
97 97
 	/**
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 * @return string
101 101
 	 */
102 102
 	public function getUrl() {
103
-		$https = Arr::get( $this->server, 'HTTPS' );
103
+		$https = Arr::get($this->server, 'HTTPS');
104 104
 
105 105
 		$protocol = $https ? 'https' : 'http';
106
-		$host = Arr::get( $this->server, 'HTTP_HOST', '' );
107
-		$uri = Arr::get( $this->server, 'REQUEST_URI', '' );
106
+		$host = Arr::get($this->server, 'HTTP_HOST', '');
107
+		$uri = Arr::get($this->server, 'REQUEST_URI', '');
108 108
 
109 109
 		return $protocol . '://' . $host . $uri;
110 110
 	}
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		$args = func_get_args();
119 119
 		$source = $this->{$args[0]};
120 120
 
121
-		if ( count( $args ) === 1 ) {
121
+		if (count($args) === 1) {
122 122
 			return $source;
123 123
 		}
124 124
 
125 125
 		$args[0] = $source;
126
-		return call_user_func_array( [Arr, 'get'], $args );
126
+		return call_user_func_array([Arr, 'get'], $args);
127 127
 	}
128 128
 
129 129
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @return string|array
133 133
 	 */
134 134
 	public function get() {
135
-		return call_user_func_array( [$this, 'input'], array_merge( ['get'], func_get_args() ) );
135
+		return call_user_func_array([$this, 'input'], array_merge(['get'], func_get_args()));
136 136
 	}
137 137
 
138 138
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return string|array
142 142
 	 */
143 143
 	public function post() {
144
-		return call_user_func_array( [$this, 'input'], array_merge( ['post'], func_get_args() ) );
144
+		return call_user_func_array([$this, 'input'], array_merge(['post'], func_get_args()));
145 145
 	}
146 146
 
147 147
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @return string|array
151 151
 	 */
152 152
 	public function cookie() {
153
-		return call_user_func_array( [$this, 'input'], array_merge( ['cookie'], func_get_args() ) );
153
+		return call_user_func_array([$this, 'input'], array_merge(['cookie'], func_get_args()));
154 154
 	}
155 155
 
156 156
 	/**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @return string|array
160 160
 	 */
161 161
 	public function files() {
162
-		return call_user_func_array( [$this, 'input'], array_merge( ['files'], func_get_args() ) );
162
+		return call_user_func_array([$this, 'input'], array_merge(['files'], func_get_args()));
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @return string|array
169 169
 	 */
170 170
 	public function server() {
171
-		return call_user_func_array( [$this, 'input'], array_merge( ['server'], func_get_args() ) );
171
+		return call_user_func_array([$this, 'input'], array_merge(['server'], func_get_args()));
172 172
 	}
173 173
 
174 174
 	/**
@@ -177,6 +177,6 @@  discard block
 block discarded – undo
177 177
 	 * @return string|array
178 178
 	 */
179 179
 	public function headers() {
180
-		return call_user_func_array( [$this, 'input'], array_merge( ['headers'], func_get_args() ) );
180
+		return call_user_func_array([$this, 'input'], array_merge(['headers'], func_get_args()));
181 181
 	}
182 182
 }
Please login to merge, or discard this patch.
src/Framework.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @return boolean
39 39
 	 */
40 40
 	public static function debugging() {
41
-		return ( defined( 'WP_DEBUG' ) && WP_DEBUG );
41
+		return (defined('WP_DEBUG') && WP_DEBUG);
42 42
 	}
43 43
 
44 44
 	/**
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	 * @return null
58 58
 	 */
59 59
 	public static function verifyBoot() {
60
-		if ( ! static::isBooted() ) {
61
-			throw new Exception( get_called_class() . ' must be booted first.' );
60
+		if ( ! static::isBooted()) {
61
+			throw new Exception(get_called_class() . ' must be booted first.');
62 62
 		}
63 63
 	}
64 64
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return Container
69 69
 	 */
70 70
 	public static function getContainer() {
71
-		if ( static::$container === null ) {
71
+		if (static::$container === null) {
72 72
 			static::$container = new Container();
73 73
 		}
74 74
 		return static::$container;
@@ -82,29 +82,29 @@  discard block
 block discarded – undo
82 82
 	 * @throws Exception
83 83
 	 * @return null
84 84
 	 */
85
-	public static function boot( $config ) {
86
-		if ( static::isBooted() ) {
87
-			throw new Exception( get_called_class() . ' already booted.' );
85
+	public static function boot($config) {
86
+		if (static::isBooted()) {
87
+			throw new Exception(get_called_class() . ' already booted.');
88 88
 		}
89 89
 		static::$booted = true;
90 90
 
91 91
 		$container = static::getContainer();
92 92
 
93
-		$container['framework.config'] = array_merge( [
93
+		$container['framework.config'] = array_merge([
94 94
 			'providers' => [],
95
-		], $config );
95
+		], $config);
96 96
 
97
-		$container['framework.service_providers'] = array_merge( [
97
+		$container['framework.service_providers'] = array_merge([
98 98
 			RoutingServiceProvider::class,
99 99
 			FlashServiceProvider::class,
100 100
 			OldInputServiceProvider::class,
101 101
 			TemplatingServiceProvider::class,
102
-		], $container['framework.config']['providers'] );
102
+		], $container['framework.config']['providers']);
103 103
 
104
-		Facade::setFacadeApplication( $container );
104
+		Facade::setFacadeApplication($container);
105 105
 		AliasLoader::getInstance()->register();
106 106
 
107
-		static::loadServiceProviders( $container );
107
+		static::loadServiceProviders($container);
108 108
 	}
109 109
 
110 110
 	/**
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	 * @param  Container $container
114 114
 	 * @return null
115 115
 	 */
116
-	protected static function loadServiceProviders( $container ) {
117
-		$container['framework.service_providers'] = apply_filters( 'carbon_framework_service_providers', $container['framework.service_providers'] );
116
+	protected static function loadServiceProviders($container) {
117
+		$container['framework.service_providers'] = apply_filters('carbon_framework_service_providers', $container['framework.service_providers']);
118 118
 
119
-		$service_providers = array_map( function( $service_provider ) {
119
+		$service_providers = array_map(function($service_provider) {
120 120
 			return new $service_provider();
121
-		}, $container['framework.service_providers'] );
121
+		}, $container['framework.service_providers']);
122 122
 
123
-		static::registerServiceProviders( $service_providers, $container );
124
-		static::bootServiceProviders( $service_providers, $container );
123
+		static::registerServiceProviders($service_providers, $container);
124
+		static::bootServiceProviders($service_providers, $container);
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @param  Container $container
131 131
 	 * @return null
132 132
 	 */
133
-	protected static function registerServiceProviders( $service_providers, $container ) {
134
-		foreach ( $service_providers as $provider ) {
135
-			$provider->register( $container );
133
+	protected static function registerServiceProviders($service_providers, $container) {
134
+		foreach ($service_providers as $provider) {
135
+			$provider->register($container);
136 136
 		}
137 137
 	}
138 138
 
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 	 * @param  Container $container
143 143
 	 * @return null
144 144
 	 */
145
-	protected static function bootServiceProviders( $service_providers, $container ) {
146
-		foreach ( $service_providers as $provider ) {
147
-			$provider->boot( $container );
145
+	protected static function bootServiceProviders($service_providers, $container) {
146
+		foreach ($service_providers as $provider) {
147
+			$provider->boot($container);
148 148
 		}
149 149
 	}
150 150
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @param  string $facade_class
156 156
 	 * @return null
157 157
 	 */
158
-	public static function facade( $alias, $facade_class ) {
159
-		AliasLoader::getInstance()->alias( $alias, $facade_class );
158
+	public static function facade($alias, $facade_class) {
159
+		AliasLoader::getInstance()->alias($alias, $facade_class);
160 160
 	}
161 161
 
162 162
 	/**
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 	 * @param  string   $key
166 166
 	 * @return any|null
167 167
 	 */
168
-	public static function resolve( $key ) {
168
+	public static function resolve($key) {
169 169
 		static::verifyBoot();
170 170
 
171
-		if ( ! isset( static::getContainer()[ $key ] ) ) {
171
+		if ( ! isset(static::getContainer()[$key])) {
172 172
 			return null;
173 173
 		}
174 174
 
175
-		return static::getContainer()[ $key ];
175
+		return static::getContainer()[$key];
176 176
 	}
177 177
 
178 178
 	/**
@@ -181,28 +181,28 @@  discard block
 block discarded – undo
181 181
 	 * @param  string $class
182 182
 	 * @return object
183 183
 	 */
184
-	public static function instantiate( $class ) {
184
+	public static function instantiate($class) {
185 185
 		static::verifyBoot();
186 186
 
187
-		$instance = static::resolve( $class );
188
-		if ( $instance === null ) {
187
+		$instance = static::resolve($class);
188
+		if ($instance === null) {
189 189
 			try {
190
-				$reflection = new ReflectionMethod( $class, '__construct' );
190
+				$reflection = new ReflectionMethod($class, '__construct');
191 191
 
192
-				if ( ! $reflection->isPublic() ) {
193
-					throw new Exception( $class . '::__construct() is not public.' );
192
+				if ( ! $reflection->isPublic()) {
193
+					throw new Exception($class . '::__construct() is not public.');
194 194
 				}
195 195
 
196 196
 				$parameters = $reflection->getParameters();
197 197
 
198
-				$required_parameters = array_filter( $parameters, function( $parameter ) {
198
+				$required_parameters = array_filter($parameters, function($parameter) {
199 199
 					return ! $parameter->isOptional();
200 200
 				} );
201 201
 
202
-				if ( ! empty( $required_parameters ) ) {
203
-					throw new Exception( $class . '::__construct() has requird parameters but could not be resolved from container. Did you miss to define it into the container?' );
202
+				if ( ! empty($required_parameters)) {
203
+					throw new Exception($class . '::__construct() has requird parameters but could not be resolved from container. Did you miss to define it into the container?');
204 204
 				}
205
-			} catch ( ReflectionException $e ) {
205
+			} catch (ReflectionException $e) {
206 206
 				// __constructor is not defined so we are free to create a new instance
207 207
 			}
208 208
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @param  ResponseInterface $response
219 219
 	 * @return null
220 220
 	 */
221
-	public static function respond( ResponseInterface $response ) {
222
-		Response::respond( $response );
221
+	public static function respond(ResponseInterface $response) {
222
+		Response::respond($response);
223 223
 	}
224 224
 }
Please login to merge, or discard this patch.
src/template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,4 +3,4 @@
 block discarded – undo
3 3
  * Template used to override the loaded template file by WordPress when a route is handled
4 4
  */
5 5
 use CarbonFramework\Framework;
6
-Framework::respond( apply_filters( 'carbon_framework_response', null ) );
6
+Framework::respond(apply_filters('carbon_framework_response', null));
Please login to merge, or discard this patch.
src/ServiceProviders/OldInput.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,22 +12,22 @@
 block discarded – undo
12 12
 	/**
13 13
 	 * {@inheritDoc}
14 14
 	 */
15
-	public function register( $container ) {
16
-		$container['framework.global_middleware'] = array_merge( $container['framework.global_middleware'], [
15
+	public function register($container) {
16
+		$container['framework.global_middleware'] = array_merge($container['framework.global_middleware'], [
17 17
 			OldInputMiddleware::class,
18
-		] );
18
+		]);
19 19
 
20
-		$container['framework.old_input.old_input'] = function( $c ) {
20
+		$container['framework.old_input.old_input'] = function($c) {
21 21
 			return new \CarbonFramework\Input\OldInput();
22 22
 		};
23 23
 
24
-		Framework::facade( 'OldInput', \CarbonFramework\Facades\OldInput::class );
24
+		Framework::facade('OldInput', \CarbonFramework\Facades\OldInput::class);
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * {@inheritDoc}
29 29
 	 */
30
-	public function boot( $container ) {
30
+	public function boot($container) {
31 31
 		// nothing to boot
32 32
 	}
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/ServiceProviders/Flash.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@
 block discarded – undo
11 11
 	/**
12 12
 	 * {@inheritDoc}
13 13
 	 */
14
-	public function register( $container ) {
15
-		$container['framework.flash.flash'] = function( $c ) {
14
+	public function register($container) {
15
+		$container['framework.flash.flash'] = function($c) {
16 16
 			$session = null;
17
-			if ( isset( $c['framework.session'] ) ) {
17
+			if (isset($c['framework.session'])) {
18 18
 				$session = $c['framework.session'];
19
-			} else if ( isset( $_SESSION ) ) {
19
+			} else if (isset($_SESSION)) {
20 20
 				$session = &$_SESSION;
21 21
 			}
22
-			return new \CarbonFramework\Flash\Flash( $session );
22
+			return new \CarbonFramework\Flash\Flash($session);
23 23
 		};
24 24
 
25
-		Framework::facade( 'Flash', \CarbonFramework\Facades\Flash::class );
25
+		Framework::facade('Flash', \CarbonFramework\Facades\Flash::class);
26 26
 	}
27 27
 
28 28
 	/**
29 29
 	 * {@inheritDoc}
30 30
 	 */
31
-	public function boot( $container ) {
31
+	public function boot($container) {
32 32
 		// nothing to boot
33 33
 	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/ServiceProviders/Templating.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * {@inheritDoc}
13 13
 	 */
14
-	public function register( $container ) {
15
-		$container['framework.templating.engine'] = function( $c ) {
14
+	public function register($container) {
15
+		$container['framework.templating.engine'] = function($c) {
16 16
 			return new \CarbonFramework\Templating\Php();
17 17
 		};
18 18
 	}
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * {@inheritDoc}
22 22
 	 */
23
-	public function boot( $container ) {
23
+	public function boot($container) {
24 24
 		// nothing to boot
25 25
 	}
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.