@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
165 | 165 | * @param string $key |
166 | 166 | * @return mixed|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,12 +181,12 @@ discard block |
||
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 ); |
|
187 | + $instance = static::resolve($class); |
|
188 | 188 | |
189 | - if ( $instance === null ) { |
|
189 | + if ($instance === null) { |
|
190 | 190 | $instance = new $class(); |
191 | 191 | } |
192 | 192 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param ResponseInterface $response |
200 | 200 | * @return null |
201 | 201 | */ |
202 | - public static function respond( ResponseInterface $response ) { |
|
203 | - Response::respond( $response ); |
|
202 | + public static function respond(ResponseInterface $response) { |
|
203 | + Response::respond($response); |
|
204 | 204 | } |
205 | 205 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param string|Closure $handler |
24 | 24 | */ |
25 | - public function __construct( $handler ) { |
|
26 | - $this->set( $handler ); |
|
25 | + public function __construct($handler) { |
|
26 | + $this->set($handler); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | * @param string|Closure $handler |
33 | 33 | * @return callable|array|null |
34 | 34 | */ |
35 | - protected function parse( $handler ) { |
|
36 | - if ( $handler instanceof Closure ) { |
|
35 | + protected function parse($handler) { |
|
36 | + if ($handler instanceof Closure) { |
|
37 | 37 | return $handler; |
38 | 38 | } |
39 | 39 | |
40 | - if ( is_string( $handler ) ) { |
|
41 | - $handlerPieces = preg_split( '/@|::/', $handler, 2 ); |
|
42 | - if ( count( $handlerPieces ) === 1 ) { |
|
43 | - if ( is_callable( $handlerPieces[0] ) ) { |
|
40 | + if (is_string($handler)) { |
|
41 | + $handlerPieces = preg_split('/@|::/', $handler, 2); |
|
42 | + if (count($handlerPieces) === 1) { |
|
43 | + if (is_callable($handlerPieces[0])) { |
|
44 | 44 | return $handlerPieces[0]; |
45 | 45 | } |
46 | 46 | return null; |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * @param string|Closure $new_handler |
61 | 61 | * @return null |
62 | 62 | */ |
63 | - public function set( $new_handler ) { |
|
64 | - $handler = $this->parse( $new_handler ); |
|
63 | + public function set($new_handler) { |
|
64 | + $handler = $this->parse($new_handler); |
|
65 | 65 | |
66 | - if ( $handler === null ) { |
|
67 | - throw new Exception( 'No or invalid handler provided.' ); |
|
66 | + if ($handler === null) { |
|
67 | + throw new Exception('No or invalid handler provided.'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->handler = $handler; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function execute() { |
79 | 79 | $arguments = func_get_args(); |
80 | - if ( is_callable( $this->handler ) ) { |
|
81 | - return call_user_func_array( $this->handler, $arguments ); |
|
80 | + if (is_callable($this->handler)) { |
|
81 | + return call_user_func_array($this->handler, $arguments); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $class = $this->handler['class']; |
85 | 85 | $method = $this->handler['method']; |
86 | 86 | |
87 | - $controller = Framework::instantiate( $class ); |
|
88 | - return call_user_func_array( [$controller, $method], $arguments ); |
|
87 | + $controller = Framework::instantiate($class); |
|
88 | + return call_user_func_array([$controller, $method], $arguments); |
|
89 | 89 | } |
90 | 90 | } |