@@ -2,6 +2,6 @@ |
||
| 2 | 2 | /** |
| 3 | 3 | * Absolute path to framework's directory |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'CARBON_FRAMEWORK_DIR' ) ) { |
|
| 6 | - define( 'CARBON_FRAMEWORK_DIR', __DIR__ ); |
|
| 5 | +if ( ! defined('CARBON_FRAMEWORK_DIR')) { |
|
| 6 | + define('CARBON_FRAMEWORK_DIR', __DIR__); |
|
| 7 | 7 | } |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class OldInput extends Facade |
| 9 | 9 | { |
| 10 | - protected static function getFacadeAccessor() |
|
| 11 | - { |
|
| 12 | - return 'framework.old_input.old_input'; |
|
| 13 | - } |
|
| 10 | + protected static function getFacadeAccessor() |
|
| 11 | + { |
|
| 12 | + return 'framework.old_input.old_input'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Router extends Facade |
| 9 | 9 | { |
| 10 | - protected static function getFacadeAccessor() |
|
| 11 | - { |
|
| 12 | - return 'framework.routing.router'; |
|
| 13 | - } |
|
| 10 | + protected static function getFacadeAccessor() |
|
| 11 | + { |
|
| 12 | + return 'framework.routing.router'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Flash extends Facade |
| 9 | 9 | { |
| 10 | - protected static function getFacadeAccessor() |
|
| 11 | - { |
|
| 12 | - return 'framework.flash.flash'; |
|
| 13 | - } |
|
| 10 | + protected static function getFacadeAccessor() |
|
| 11 | + { |
|
| 12 | + return 'framework.flash.flash'; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -12,216 +12,216 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class Facade |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * The application instance being facaded. |
|
| 17 | - * |
|
| 18 | - * @var object |
|
| 19 | - */ |
|
| 20 | - protected static $app; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * The resolved object instances. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - protected static $resolvedInstance; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Convert the facade into a Mockery spy. |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public static function spy() |
|
| 35 | - { |
|
| 36 | - if (! static::isMock()) { |
|
| 37 | - $class = static::getMockableClass(); |
|
| 38 | - |
|
| 39 | - static::swap($class ? Mockery::spy($class) : Mockery::spy()); |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Initiate a mock expectation on the facade. |
|
| 45 | - * |
|
| 46 | - * @return \Mockery\Expectation |
|
| 47 | - */ |
|
| 48 | - public static function shouldReceive() |
|
| 49 | - { |
|
| 50 | - $name = static::getFacadeAccessor(); |
|
| 51 | - |
|
| 52 | - $mock = static::isMock() |
|
| 53 | - ? static::$resolvedInstance[$name] |
|
| 54 | - : static::createFreshMockInstance(); |
|
| 55 | - |
|
| 56 | - return $mock->shouldReceive(...func_get_args()); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Create a fresh mock instance for the given class. |
|
| 61 | - * |
|
| 62 | - * @return \Mockery\Expectation |
|
| 63 | - */ |
|
| 64 | - protected static function createFreshMockInstance() |
|
| 65 | - { |
|
| 66 | - return tap(static::createMock(), function ($mock) { |
|
| 67 | - static::swap($mock); |
|
| 68 | - |
|
| 69 | - $mock->shouldAllowMockingProtectedMethods(); |
|
| 70 | - }); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Create a fresh mock instance for the given class. |
|
| 75 | - * |
|
| 76 | - * @return \Mockery\MockInterface |
|
| 77 | - */ |
|
| 78 | - protected static function createMock() |
|
| 79 | - { |
|
| 80 | - $class = static::getMockableClass(); |
|
| 81 | - |
|
| 82 | - return $class ? Mockery::mock($class) : Mockery::mock(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Determines whether a mock is set as the instance of the facade. |
|
| 87 | - * |
|
| 88 | - * @return bool |
|
| 89 | - */ |
|
| 90 | - protected static function isMock() |
|
| 91 | - { |
|
| 92 | - $name = static::getFacadeAccessor(); |
|
| 93 | - |
|
| 94 | - return isset(static::$resolvedInstance[$name]) && |
|
| 95 | - static::$resolvedInstance[$name] instanceof MockInterface; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Get the mockable class for the bound instance. |
|
| 100 | - * |
|
| 101 | - * @return string|null |
|
| 102 | - */ |
|
| 103 | - protected static function getMockableClass() |
|
| 104 | - { |
|
| 105 | - if ($root = static::getFacadeRoot()) { |
|
| 106 | - return get_class($root); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Hotswap the underlying instance behind the facade. |
|
| 112 | - * |
|
| 113 | - * @param mixed $instance |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 116 | - public static function swap($instance) |
|
| 117 | - { |
|
| 118 | - static::$resolvedInstance[static::getFacadeAccessor()] = $instance; |
|
| 119 | - |
|
| 120 | - if (isset(static::$app)) { |
|
| 121 | - static::$app->instance(static::getFacadeAccessor(), $instance); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Get the root object behind the facade. |
|
| 127 | - * |
|
| 128 | - * @return mixed |
|
| 129 | - */ |
|
| 130 | - public static function getFacadeRoot() |
|
| 131 | - { |
|
| 132 | - return static::resolveFacadeInstance(static::getFacadeAccessor()); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Get the registered name of the component. |
|
| 137 | - * |
|
| 138 | - * @return string |
|
| 139 | - * |
|
| 140 | - * @throws \RuntimeException |
|
| 141 | - */ |
|
| 142 | - protected static function getFacadeAccessor() |
|
| 143 | - { |
|
| 144 | - throw new RuntimeException('Facade does not implement getFacadeAccessor method.'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Resolve the facade root instance from the container. |
|
| 149 | - * |
|
| 150 | - * @param string|object $name |
|
| 151 | - * @return mixed |
|
| 152 | - */ |
|
| 153 | - protected static function resolveFacadeInstance($name) |
|
| 154 | - { |
|
| 155 | - if (is_object($name)) { |
|
| 156 | - return $name; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (isset(static::$resolvedInstance[$name])) { |
|
| 160 | - return static::$resolvedInstance[$name]; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return static::$resolvedInstance[$name] = static::$app[$name]; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Clear a resolved facade instance. |
|
| 168 | - * |
|
| 169 | - * @param string $name |
|
| 170 | - * @return void |
|
| 171 | - */ |
|
| 172 | - public static function clearResolvedInstance($name) |
|
| 173 | - { |
|
| 174 | - unset(static::$resolvedInstance[$name]); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Clear all of the resolved instances. |
|
| 179 | - * |
|
| 180 | - * @return void |
|
| 181 | - */ |
|
| 182 | - public static function clearResolvedInstances() |
|
| 183 | - { |
|
| 184 | - static::$resolvedInstance = []; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Get the application instance behind the facade. |
|
| 189 | - * |
|
| 190 | - * @return object |
|
| 191 | - */ |
|
| 192 | - public static function getFacadeApplication() |
|
| 193 | - { |
|
| 194 | - return static::$app; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Set the application instance. |
|
| 199 | - * |
|
| 200 | - * @param object $app |
|
| 201 | - * @return void |
|
| 202 | - */ |
|
| 203 | - public static function setFacadeApplication($app) |
|
| 204 | - { |
|
| 205 | - static::$app = $app; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Handle dynamic, static calls to the object. |
|
| 210 | - * |
|
| 211 | - * @param string $method |
|
| 212 | - * @param array $args |
|
| 213 | - * @return mixed |
|
| 214 | - * |
|
| 215 | - * @throws \RuntimeException |
|
| 216 | - */ |
|
| 217 | - public static function __callStatic($method, $args) |
|
| 218 | - { |
|
| 219 | - $instance = static::getFacadeRoot(); |
|
| 220 | - |
|
| 221 | - if (! $instance) { |
|
| 222 | - throw new RuntimeException('A facade root has not been set.'); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - return $instance->$method(...$args); |
|
| 226 | - } |
|
| 15 | + /** |
|
| 16 | + * The application instance being facaded. |
|
| 17 | + * |
|
| 18 | + * @var object |
|
| 19 | + */ |
|
| 20 | + protected static $app; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * The resolved object instances. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + protected static $resolvedInstance; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Convert the facade into a Mockery spy. |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public static function spy() |
|
| 35 | + { |
|
| 36 | + if (! static::isMock()) { |
|
| 37 | + $class = static::getMockableClass(); |
|
| 38 | + |
|
| 39 | + static::swap($class ? Mockery::spy($class) : Mockery::spy()); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Initiate a mock expectation on the facade. |
|
| 45 | + * |
|
| 46 | + * @return \Mockery\Expectation |
|
| 47 | + */ |
|
| 48 | + public static function shouldReceive() |
|
| 49 | + { |
|
| 50 | + $name = static::getFacadeAccessor(); |
|
| 51 | + |
|
| 52 | + $mock = static::isMock() |
|
| 53 | + ? static::$resolvedInstance[$name] |
|
| 54 | + : static::createFreshMockInstance(); |
|
| 55 | + |
|
| 56 | + return $mock->shouldReceive(...func_get_args()); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Create a fresh mock instance for the given class. |
|
| 61 | + * |
|
| 62 | + * @return \Mockery\Expectation |
|
| 63 | + */ |
|
| 64 | + protected static function createFreshMockInstance() |
|
| 65 | + { |
|
| 66 | + return tap(static::createMock(), function ($mock) { |
|
| 67 | + static::swap($mock); |
|
| 68 | + |
|
| 69 | + $mock->shouldAllowMockingProtectedMethods(); |
|
| 70 | + }); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Create a fresh mock instance for the given class. |
|
| 75 | + * |
|
| 76 | + * @return \Mockery\MockInterface |
|
| 77 | + */ |
|
| 78 | + protected static function createMock() |
|
| 79 | + { |
|
| 80 | + $class = static::getMockableClass(); |
|
| 81 | + |
|
| 82 | + return $class ? Mockery::mock($class) : Mockery::mock(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Determines whether a mock is set as the instance of the facade. |
|
| 87 | + * |
|
| 88 | + * @return bool |
|
| 89 | + */ |
|
| 90 | + protected static function isMock() |
|
| 91 | + { |
|
| 92 | + $name = static::getFacadeAccessor(); |
|
| 93 | + |
|
| 94 | + return isset(static::$resolvedInstance[$name]) && |
|
| 95 | + static::$resolvedInstance[$name] instanceof MockInterface; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Get the mockable class for the bound instance. |
|
| 100 | + * |
|
| 101 | + * @return string|null |
|
| 102 | + */ |
|
| 103 | + protected static function getMockableClass() |
|
| 104 | + { |
|
| 105 | + if ($root = static::getFacadeRoot()) { |
|
| 106 | + return get_class($root); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Hotswap the underlying instance behind the facade. |
|
| 112 | + * |
|
| 113 | + * @param mixed $instance |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | + public static function swap($instance) |
|
| 117 | + { |
|
| 118 | + static::$resolvedInstance[static::getFacadeAccessor()] = $instance; |
|
| 119 | + |
|
| 120 | + if (isset(static::$app)) { |
|
| 121 | + static::$app->instance(static::getFacadeAccessor(), $instance); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Get the root object behind the facade. |
|
| 127 | + * |
|
| 128 | + * @return mixed |
|
| 129 | + */ |
|
| 130 | + public static function getFacadeRoot() |
|
| 131 | + { |
|
| 132 | + return static::resolveFacadeInstance(static::getFacadeAccessor()); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Get the registered name of the component. |
|
| 137 | + * |
|
| 138 | + * @return string |
|
| 139 | + * |
|
| 140 | + * @throws \RuntimeException |
|
| 141 | + */ |
|
| 142 | + protected static function getFacadeAccessor() |
|
| 143 | + { |
|
| 144 | + throw new RuntimeException('Facade does not implement getFacadeAccessor method.'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Resolve the facade root instance from the container. |
|
| 149 | + * |
|
| 150 | + * @param string|object $name |
|
| 151 | + * @return mixed |
|
| 152 | + */ |
|
| 153 | + protected static function resolveFacadeInstance($name) |
|
| 154 | + { |
|
| 155 | + if (is_object($name)) { |
|
| 156 | + return $name; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (isset(static::$resolvedInstance[$name])) { |
|
| 160 | + return static::$resolvedInstance[$name]; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return static::$resolvedInstance[$name] = static::$app[$name]; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Clear a resolved facade instance. |
|
| 168 | + * |
|
| 169 | + * @param string $name |
|
| 170 | + * @return void |
|
| 171 | + */ |
|
| 172 | + public static function clearResolvedInstance($name) |
|
| 173 | + { |
|
| 174 | + unset(static::$resolvedInstance[$name]); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Clear all of the resolved instances. |
|
| 179 | + * |
|
| 180 | + * @return void |
|
| 181 | + */ |
|
| 182 | + public static function clearResolvedInstances() |
|
| 183 | + { |
|
| 184 | + static::$resolvedInstance = []; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Get the application instance behind the facade. |
|
| 189 | + * |
|
| 190 | + * @return object |
|
| 191 | + */ |
|
| 192 | + public static function getFacadeApplication() |
|
| 193 | + { |
|
| 194 | + return static::$app; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Set the application instance. |
|
| 199 | + * |
|
| 200 | + * @param object $app |
|
| 201 | + * @return void |
|
| 202 | + */ |
|
| 203 | + public static function setFacadeApplication($app) |
|
| 204 | + { |
|
| 205 | + static::$app = $app; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Handle dynamic, static calls to the object. |
|
| 210 | + * |
|
| 211 | + * @param string $method |
|
| 212 | + * @param array $args |
|
| 213 | + * @return mixed |
|
| 214 | + * |
|
| 215 | + * @throws \RuntimeException |
|
| 216 | + */ |
|
| 217 | + public static function __callStatic($method, $args) |
|
| 218 | + { |
|
| 219 | + $instance = static::getFacadeRoot(); |
|
| 220 | + |
|
| 221 | + if (! $instance) { |
|
| 222 | + throw new RuntimeException('A facade root has not been set.'); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + return $instance->$method(...$args); |
|
| 226 | + } |
|
| 227 | 227 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function spy() |
| 35 | 35 | { |
| 36 | - if (! static::isMock()) { |
|
| 36 | + if ( ! static::isMock()) { |
|
| 37 | 37 | $class = static::getMockableClass(); |
| 38 | 38 | |
| 39 | 39 | static::swap($class ? Mockery::spy($class) : Mockery::spy()); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected static function createFreshMockInstance() |
| 65 | 65 | { |
| 66 | - return tap(static::createMock(), function ($mock) { |
|
| 66 | + return tap(static::createMock(), function($mock) { |
|
| 67 | 67 | static::swap($mock); |
| 68 | 68 | |
| 69 | 69 | $mock->shouldAllowMockingProtectedMethods(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | { |
| 219 | 219 | $instance = static::getFacadeRoot(); |
| 220 | 220 | |
| 221 | - if (! $instance) { |
|
| 221 | + if ( ! $instance) { |
|
| 222 | 222 | throw new RuntimeException('A facade root has not been set.'); |
| 223 | 223 | } |
| 224 | 224 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | 33 | public static function all() { |
| 34 | - return Flash::peek( static::getFlashKey() ); |
|
| 34 | + return Flash::peek(static::getFlashKey()); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @see Arr::get() |
| 41 | 41 | */ |
| 42 | 42 | public static function get() { |
| 43 | - $arguments = array_merge( [ |
|
| 43 | + $arguments = array_merge([ |
|
| 44 | 44 | static::all(), |
| 45 | - ], func_get_args() ); |
|
| 46 | - return call_user_func_array( [Arr::class, 'get'], $arguments ); |
|
| 45 | + ], func_get_args()); |
|
| 46 | + return call_user_func_array([Arr::class, 'get'], $arguments); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -13,5 +13,5 @@ |
||
| 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 |
@@ -9,13 +9,13 @@ |
||
| 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(); |
@@ -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 | } |