@@ -26,9 +26,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -3,4 +3,4 @@ |
||
| 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)); |
|
@@ -11,24 +11,24 @@ |
||
| 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 |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @param \Pimple\Container $container |
| 13 | 13 | * @return null |
| 14 | 14 | */ |
| 15 | - public function register( $container ); |
|
| 15 | + public function register($container); |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Bootstrap any services if needed |
@@ -20,5 +20,5 @@ discard block |
||
| 20 | 20 | * @param \Pimple\Container $container |
| 21 | 21 | * @return null |
| 22 | 22 | */ |
| 23 | - public function boot( $container ); |
|
| 23 | + public function boot($container); |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | * @param \CarbonFramework\Request $request |
| 22 | 22 | * @return \Psr\Http\Message\ResponseInterface |
| 23 | 23 | */ |
| 24 | - public function handle( $request ); |
|
| 24 | + public function handle($request); |
|
| 25 | 25 | } |
@@ -14,5 +14,5 @@ |
||
| 14 | 14 | * @param \CarbonFramework\Request $request |
| 15 | 15 | * @param Closure $next |
| 16 | 16 | */ |
| 17 | - public function handle( $request, Closure $next ); |
|
| 17 | + public function handle($request, Closure $next); |
|
| 18 | 18 | } |
@@ -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 | } |