@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | public function setEditor($editor) |
| 358 | 358 | { |
| 359 | 359 | if ( ! is_callable($editor) && ! isset($this->editors[$editor])) { |
| 360 | - throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
| 360 | + throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: ". |
|
| 361 | 361 | implode(', ', array_keys($this->editors)) |
| 362 | 362 | ); |
| 363 | 363 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | { |
| 381 | 381 | $editor = $this->getEditor($file, $line); |
| 382 | 382 | |
| 383 | - if (empty($editor)) { |
|
| 383 | + if (empty($editor)) { |
|
| 384 | 384 | return false; |
| 385 | 385 | } |
| 386 | 386 | |
@@ -333,7 +333,9 @@ |
||
| 333 | 333 | |
| 334 | 334 | $vars = $this->collectionVars(); |
| 335 | 335 | |
| 336 | - if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
| 336 | + if (empty($vars['message'])) { |
|
| 337 | + $vars['message'] = __('exception.noMessage'); |
|
| 338 | + } |
|
| 337 | 339 | |
| 338 | 340 | $this->template->setVariables($vars); |
| 339 | 341 | $this->template->render($templatePath); |
@@ -39,430 +39,430 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class PleasingPageHandler extends MainHandler |
| 41 | 41 | { |
| 42 | - /** |
|
| 43 | - * The brand main of handler. |
|
| 44 | - * |
|
| 45 | - * @var string $brand |
|
| 46 | - */ |
|
| 47 | - protected $brand = 'Lenevor Debug'; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A string identifier for a known IDE/text editor, or a closure |
|
| 51 | - * that resolves a string that can be used to open a given file |
|
| 52 | - * in an editor. |
|
| 53 | - * |
|
| 54 | - * @var mixed $editor |
|
| 55 | - */ |
|
| 56 | - protected $editor; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * A list of known editor strings. |
|
| 60 | - * |
|
| 61 | - * @var array $editors |
|
| 62 | - */ |
|
| 63 | - protected $editors = [ |
|
| 64 | - "vscode" => "vscode://file/%file:%line", |
|
| 65 | - "sublime" => "subl://open?url=file://%file&line=%line", |
|
| 66 | - "phpstorm" => "phpstorm://open?file://%file&line=%line", |
|
| 67 | - "textmate" => "txmt://open?url=file://%file&line=%line", |
|
| 68 | - "atom" => "atom://core/open/file?filename=%file&line=%line", |
|
| 69 | - ]; |
|
| 42 | + /** |
|
| 43 | + * The brand main of handler. |
|
| 44 | + * |
|
| 45 | + * @var string $brand |
|
| 46 | + */ |
|
| 47 | + protected $brand = 'Lenevor Debug'; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A string identifier for a known IDE/text editor, or a closure |
|
| 51 | + * that resolves a string that can be used to open a given file |
|
| 52 | + * in an editor. |
|
| 53 | + * |
|
| 54 | + * @var mixed $editor |
|
| 55 | + */ |
|
| 56 | + protected $editor; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * A list of known editor strings. |
|
| 60 | + * |
|
| 61 | + * @var array $editors |
|
| 62 | + */ |
|
| 63 | + protected $editors = [ |
|
| 64 | + "vscode" => "vscode://file/%file:%line", |
|
| 65 | + "sublime" => "subl://open?url=file://%file&line=%line", |
|
| 66 | + "phpstorm" => "phpstorm://open?file://%file&line=%line", |
|
| 67 | + "textmate" => "txmt://open?url=file://%file&line=%line", |
|
| 68 | + "atom" => "atom://core/open/file?filename=%file&line=%line", |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * The page title main of handler. |
|
| 73 | - * |
|
| 74 | - * @var string $pageTitle |
|
| 75 | - */ |
|
| 76 | - protected $pageTitle = 'Lenevor Debug! There was an error.'; |
|
| 71 | + /** |
|
| 72 | + * The page title main of handler. |
|
| 73 | + * |
|
| 74 | + * @var string $pageTitle |
|
| 75 | + */ |
|
| 76 | + protected $pageTitle = 'Lenevor Debug! There was an error.'; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Fast lookup cache for known resource locations. |
|
| 80 | - * |
|
| 81 | - * @var array $resourceCache |
|
| 82 | - */ |
|
| 83 | - protected $resourceCache = []; |
|
| 78 | + /** |
|
| 79 | + * Fast lookup cache for known resource locations. |
|
| 80 | + * |
|
| 81 | + * @var array $resourceCache |
|
| 82 | + */ |
|
| 83 | + protected $resourceCache = []; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * The path to the directory containing the html error template directories. |
|
| 87 | - * |
|
| 88 | - * @var array $searchPaths |
|
| 89 | - */ |
|
| 90 | - protected $searchPaths = []; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Gets the table of data. |
|
| 94 | - * |
|
| 95 | - * @var array $tables |
|
| 96 | - */ |
|
| 97 | - protected $tables = []; |
|
| 85 | + /** |
|
| 86 | + * The path to the directory containing the html error template directories. |
|
| 87 | + * |
|
| 88 | + * @var array $searchPaths |
|
| 89 | + */ |
|
| 90 | + protected $searchPaths = []; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Gets the table of data. |
|
| 94 | + * |
|
| 95 | + * @var array $tables |
|
| 96 | + */ |
|
| 97 | + protected $tables = []; |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * The template handler system. |
|
| 101 | - * |
|
| 102 | - * @var string|object $template |
|
| 103 | - */ |
|
| 104 | - protected $template; |
|
| 99 | + /** |
|
| 100 | + * The template handler system. |
|
| 101 | + * |
|
| 102 | + * @var string|object $template |
|
| 103 | + */ |
|
| 104 | + protected $template; |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Constructor. The PleasingPageHandler class. |
|
| 108 | - * |
|
| 109 | - * @return void |
|
| 110 | - */ |
|
| 111 | - public function __construct() |
|
| 112 | - { |
|
| 113 | - $this->template = new TemplateHandler; |
|
| 114 | - $this->searchPaths[] = dirname(__DIR__).DIRECTORY_SEPARATOR.'Resources'; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Adds an editor resolver, identified by a string name, and that may be a |
|
| 119 | - * string path, or a callable resolver. |
|
| 120 | - * |
|
| 121 | - * @param string $identifier |
|
| 122 | - * @param string|\Callable $resolver |
|
| 123 | - * |
|
| 124 | - * @return void |
|
| 125 | - */ |
|
| 126 | - public function addEditor($identifier, $resolver): void |
|
| 127 | - { |
|
| 128 | - $this->editors[$identifier] = $resolver; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Adds an entry to the list of tables displayed in the template. |
|
| 133 | - * The expected data is a simple associative array. Any nested arrays |
|
| 134 | - * will be flattened with print_r. |
|
| 135 | - * |
|
| 136 | - * @param \Syscodes\Components\Contracts\Debug\Table $table |
|
| 137 | - * |
|
| 138 | - * @return void |
|
| 139 | - */ |
|
| 140 | - public function addTables(Table $table): void |
|
| 141 | - { |
|
| 142 | - $this->tables[] = $table; |
|
| 143 | - } |
|
| 106 | + /** |
|
| 107 | + * Constructor. The PleasingPageHandler class. |
|
| 108 | + * |
|
| 109 | + * @return void |
|
| 110 | + */ |
|
| 111 | + public function __construct() |
|
| 112 | + { |
|
| 113 | + $this->template = new TemplateHandler; |
|
| 114 | + $this->searchPaths[] = dirname(__DIR__).DIRECTORY_SEPARATOR.'Resources'; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Adds an editor resolver, identified by a string name, and that may be a |
|
| 119 | + * string path, or a callable resolver. |
|
| 120 | + * |
|
| 121 | + * @param string $identifier |
|
| 122 | + * @param string|\Callable $resolver |
|
| 123 | + * |
|
| 124 | + * @return void |
|
| 125 | + */ |
|
| 126 | + public function addEditor($identifier, $resolver): void |
|
| 127 | + { |
|
| 128 | + $this->editors[$identifier] = $resolver; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Adds an entry to the list of tables displayed in the template. |
|
| 133 | + * The expected data is a simple associative array. Any nested arrays |
|
| 134 | + * will be flattened with print_r. |
|
| 135 | + * |
|
| 136 | + * @param \Syscodes\Components\Contracts\Debug\Table $table |
|
| 137 | + * |
|
| 138 | + * @return void |
|
| 139 | + */ |
|
| 140 | + public function addTables(Table $table): void |
|
| 141 | + { |
|
| 142 | + $this->tables[] = $table; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Gathers the variables that will be made available to the view. |
|
| 147 | - * |
|
| 148 | - * @return array |
|
| 149 | - */ |
|
| 150 | - protected function collectionVars(): array |
|
| 151 | - { |
|
| 152 | - $supervisor = $this->getSupervisor(); |
|
| 153 | - $style = file_get_contents($this->getResource('css/debug.base.css')); |
|
| 154 | - $jscript = file_get_contents($this->getResource('js/debug.base.js')); |
|
| 155 | - $tables = array_merge($this->getDefaultTables(), $this->tables); |
|
| 145 | + /** |
|
| 146 | + * Gathers the variables that will be made available to the view. |
|
| 147 | + * |
|
| 148 | + * @return array |
|
| 149 | + */ |
|
| 150 | + protected function collectionVars(): array |
|
| 151 | + { |
|
| 152 | + $supervisor = $this->getSupervisor(); |
|
| 153 | + $style = file_get_contents($this->getResource('css/debug.base.css')); |
|
| 154 | + $jscript = file_get_contents($this->getResource('js/debug.base.js')); |
|
| 155 | + $tables = array_merge($this->getDefaultTables(), $this->tables); |
|
| 156 | 156 | |
| 157 | - return [ |
|
| 158 | - 'class' => explode('\\', $supervisor->getExceptionName()), |
|
| 159 | - 'stylesheet' => preg_replace('#[\r\n\t ]+#', ' ', $style), |
|
| 160 | - 'javascript' => preg_replace('#[\r\n\t ]+#', ' ', $jscript), |
|
| 161 | - 'header' => $this->getResource('views/header.php'), |
|
| 162 | - 'sidebar' => $this->getResource('views/sidebar.php'), |
|
| 163 | - 'frame_main' => $this->getResource('views/frame_main.php'), |
|
| 164 | - 'frame_description' => $this->getResource('views/frame_description.php'), |
|
| 165 | - 'frame_list' => $this->getResource('views/frame_list.php'), |
|
| 166 | - 'details_panel' => $this->getResource('views/details_panel.php'), |
|
| 167 | - 'code_source' => $this->getResource('views/code_source.php'), |
|
| 168 | - 'details_content' => $this->getResource('views/details_content.php'), |
|
| 169 | - 'footer' => $this->getResource('views/footer.php'), |
|
| 170 | - 'plain_exception' => Formatter::formatExceptionAsPlainText($this->getSupervisor()), |
|
| 171 | - 'handler' => $this, |
|
| 172 | - 'handlers' => $this->getDebug()->getHandlers(), |
|
| 173 | - 'debug' => $this->getDebug(), |
|
| 174 | - 'code' => $this->getExceptionCode(), |
|
| 175 | - 'message' => $supervisor->getExceptionMessage(), |
|
| 176 | - 'frames' => $this->getExceptionFrames(), |
|
| 177 | - 'tables' => $this->getProcessTables($tables), |
|
| 178 | - ]; |
|
| 179 | - } |
|
| 157 | + return [ |
|
| 158 | + 'class' => explode('\\', $supervisor->getExceptionName()), |
|
| 159 | + 'stylesheet' => preg_replace('#[\r\n\t ]+#', ' ', $style), |
|
| 160 | + 'javascript' => preg_replace('#[\r\n\t ]+#', ' ', $jscript), |
|
| 161 | + 'header' => $this->getResource('views/header.php'), |
|
| 162 | + 'sidebar' => $this->getResource('views/sidebar.php'), |
|
| 163 | + 'frame_main' => $this->getResource('views/frame_main.php'), |
|
| 164 | + 'frame_description' => $this->getResource('views/frame_description.php'), |
|
| 165 | + 'frame_list' => $this->getResource('views/frame_list.php'), |
|
| 166 | + 'details_panel' => $this->getResource('views/details_panel.php'), |
|
| 167 | + 'code_source' => $this->getResource('views/code_source.php'), |
|
| 168 | + 'details_content' => $this->getResource('views/details_content.php'), |
|
| 169 | + 'footer' => $this->getResource('views/footer.php'), |
|
| 170 | + 'plain_exception' => Formatter::formatExceptionAsPlainText($this->getSupervisor()), |
|
| 171 | + 'handler' => $this, |
|
| 172 | + 'handlers' => $this->getDebug()->getHandlers(), |
|
| 173 | + 'debug' => $this->getDebug(), |
|
| 174 | + 'code' => $this->getExceptionCode(), |
|
| 175 | + 'message' => $supervisor->getExceptionMessage(), |
|
| 176 | + 'frames' => $this->getExceptionFrames(), |
|
| 177 | + 'tables' => $this->getProcessTables($tables), |
|
| 178 | + ]; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * The way in which the data sender (usually the server) can tell the recipient |
|
| 183 | - * (the browser, in general) what type of data is being sent in this case, html format tagged. |
|
| 184 | - * |
|
| 185 | - * @return string |
|
| 186 | - */ |
|
| 187 | - public function contentType(): string |
|
| 188 | - { |
|
| 189 | - return 'text/html;charset=UTF-8'; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Gets the brand of project. |
|
| 194 | - * |
|
| 195 | - * @return string |
|
| 196 | - */ |
|
| 197 | - public function getBrand(): string |
|
| 198 | - { |
|
| 199 | - return $this->brand; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Returns the default tables. |
|
| 204 | - * |
|
| 205 | - * @return \Syscodes\Components\Contracts\Debug\Table[] |
|
| 206 | - */ |
|
| 207 | - protected function getDefaultTables() |
|
| 208 | - { |
|
| 209 | - return [ |
|
| 210 | - new ArrayTable('GET Data', $_GET), |
|
| 211 | - new ArrayTable('POST Data', $_POST), |
|
| 212 | - new ArrayTable('Files', $_FILES), |
|
| 213 | - new ArrayTable('Cookie', $_COOKIE), |
|
| 214 | - new ArrayTable('Session', isset($_SESSION) ? $_SESSION : []), |
|
| 215 | - new ArrayTable('Server/Request Data', $_SERVER), |
|
| 216 | - new ArrayTable(__('exception.environmentVars'), $_ENV), |
|
| 217 | - ]; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Get the code of the exception that is currently being handled. |
|
| 222 | - * |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - protected function getExceptionCode() |
|
| 226 | - { |
|
| 227 | - $exception = $this->getException(); |
|
| 228 | - $code = $exception->getCode(); |
|
| 229 | - |
|
| 230 | - if ($exception instanceof ErrorException) { |
|
| 231 | - $code = Misc::translateErrorCode($exception->getSeverity()); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return (string) $code; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Get the stack trace frames of the exception that is currently being handled. |
|
| 239 | - * |
|
| 240 | - * @return \Syscodes\Components\Debug\Engine\Supervisor; |
|
| 241 | - */ |
|
| 242 | - protected function getExceptionFrames() |
|
| 243 | - { |
|
| 244 | - $frames = $this->getSupervisor()->getFrames(); |
|
| 181 | + /** |
|
| 182 | + * The way in which the data sender (usually the server) can tell the recipient |
|
| 183 | + * (the browser, in general) what type of data is being sent in this case, html format tagged. |
|
| 184 | + * |
|
| 185 | + * @return string |
|
| 186 | + */ |
|
| 187 | + public function contentType(): string |
|
| 188 | + { |
|
| 189 | + return 'text/html;charset=UTF-8'; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Gets the brand of project. |
|
| 194 | + * |
|
| 195 | + * @return string |
|
| 196 | + */ |
|
| 197 | + public function getBrand(): string |
|
| 198 | + { |
|
| 199 | + return $this->brand; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Returns the default tables. |
|
| 204 | + * |
|
| 205 | + * @return \Syscodes\Components\Contracts\Debug\Table[] |
|
| 206 | + */ |
|
| 207 | + protected function getDefaultTables() |
|
| 208 | + { |
|
| 209 | + return [ |
|
| 210 | + new ArrayTable('GET Data', $_GET), |
|
| 211 | + new ArrayTable('POST Data', $_POST), |
|
| 212 | + new ArrayTable('Files', $_FILES), |
|
| 213 | + new ArrayTable('Cookie', $_COOKIE), |
|
| 214 | + new ArrayTable('Session', isset($_SESSION) ? $_SESSION : []), |
|
| 215 | + new ArrayTable('Server/Request Data', $_SERVER), |
|
| 216 | + new ArrayTable(__('exception.environmentVars'), $_ENV), |
|
| 217 | + ]; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Get the code of the exception that is currently being handled. |
|
| 222 | + * |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + protected function getExceptionCode() |
|
| 226 | + { |
|
| 227 | + $exception = $this->getException(); |
|
| 228 | + $code = $exception->getCode(); |
|
| 229 | + |
|
| 230 | + if ($exception instanceof ErrorException) { |
|
| 231 | + $code = Misc::translateErrorCode($exception->getSeverity()); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return (string) $code; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Get the stack trace frames of the exception that is currently being handled. |
|
| 239 | + * |
|
| 240 | + * @return \Syscodes\Components\Debug\Engine\Supervisor; |
|
| 241 | + */ |
|
| 242 | + protected function getExceptionFrames() |
|
| 243 | + { |
|
| 244 | + $frames = $this->getSupervisor()->getFrames(); |
|
| 245 | 245 | |
| 246 | - return $frames; |
|
| 247 | - } |
|
| 246 | + return $frames; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Gets the page title web. |
|
| 251 | - * |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 254 | - public function getPageTitle(): string |
|
| 255 | - { |
|
| 256 | - return $this->pageTitle; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * Processes an array of tables making sure everything is allright. |
|
| 261 | - * |
|
| 262 | - * @param \Syscodes\Components\Contracts\Debug\Table[] $tables |
|
| 263 | - * |
|
| 264 | - * @return array |
|
| 265 | - */ |
|
| 266 | - protected function getProcessTables(array $tables): array |
|
| 267 | - { |
|
| 268 | - $processTables = []; |
|
| 269 | - |
|
| 270 | - foreach ($tables as $table) { |
|
| 271 | - if ( ! $table instanceof Table) { |
|
| 272 | - continue; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $label = $table->getLabel(); |
|
| 276 | - |
|
| 277 | - try { |
|
| 278 | - $data = $table->getData(); |
|
| 279 | - |
|
| 280 | - if ( ! (is_array($data) || $data instanceof Traversable)) { |
|
| 281 | - $data = []; |
|
| 282 | - } |
|
| 283 | - } catch (Exception $e) { |
|
| 284 | - $data = []; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - $processTables[$label] = $data; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - return $processTables; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Finds a resource, by its relative path, in all available search paths. |
|
| 295 | - * |
|
| 296 | - * @param string $resource |
|
| 297 | - * |
|
| 298 | - * @return string |
|
| 299 | - * |
|
| 300 | - * @throws \RuntimeException |
|
| 301 | - */ |
|
| 302 | - protected function getResource($resource) |
|
| 303 | - { |
|
| 304 | - if (isset($this->resourceCache[$resource])) { |
|
| 305 | - return $this->resourceCache[$resource]; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - foreach ($this->searchPaths as $path) { |
|
| 309 | - $fullPath = $path.DIRECTORY_SEPARATOR.$resource; |
|
| 310 | - |
|
| 311 | - if (is_file($fullPath)) { |
|
| 312 | - // Cache: |
|
| 313 | - $this->resourceCache[$resource] = $fullPath; |
|
| 314 | - |
|
| 315 | - return $fullPath; |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - throw new RuntimeException( |
|
| 320 | - "Could not find resource '{$resource}' in any resource paths.". |
|
| 321 | - "(searched: ".join(", ", $this->searchPaths).")"); |
|
| 322 | - } |
|
| 249 | + /** |
|
| 250 | + * Gets the page title web. |
|
| 251 | + * |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | + public function getPageTitle(): string |
|
| 255 | + { |
|
| 256 | + return $this->pageTitle; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * Processes an array of tables making sure everything is allright. |
|
| 261 | + * |
|
| 262 | + * @param \Syscodes\Components\Contracts\Debug\Table[] $tables |
|
| 263 | + * |
|
| 264 | + * @return array |
|
| 265 | + */ |
|
| 266 | + protected function getProcessTables(array $tables): array |
|
| 267 | + { |
|
| 268 | + $processTables = []; |
|
| 269 | + |
|
| 270 | + foreach ($tables as $table) { |
|
| 271 | + if ( ! $table instanceof Table) { |
|
| 272 | + continue; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $label = $table->getLabel(); |
|
| 276 | + |
|
| 277 | + try { |
|
| 278 | + $data = $table->getData(); |
|
| 279 | + |
|
| 280 | + if ( ! (is_array($data) || $data instanceof Traversable)) { |
|
| 281 | + $data = []; |
|
| 282 | + } |
|
| 283 | + } catch (Exception $e) { |
|
| 284 | + $data = []; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + $processTables[$label] = $data; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + return $processTables; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Finds a resource, by its relative path, in all available search paths. |
|
| 295 | + * |
|
| 296 | + * @param string $resource |
|
| 297 | + * |
|
| 298 | + * @return string |
|
| 299 | + * |
|
| 300 | + * @throws \RuntimeException |
|
| 301 | + */ |
|
| 302 | + protected function getResource($resource) |
|
| 303 | + { |
|
| 304 | + if (isset($this->resourceCache[$resource])) { |
|
| 305 | + return $this->resourceCache[$resource]; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + foreach ($this->searchPaths as $path) { |
|
| 309 | + $fullPath = $path.DIRECTORY_SEPARATOR.$resource; |
|
| 310 | + |
|
| 311 | + if (is_file($fullPath)) { |
|
| 312 | + // Cache: |
|
| 313 | + $this->resourceCache[$resource] = $fullPath; |
|
| 314 | + |
|
| 315 | + return $fullPath; |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + throw new RuntimeException( |
|
| 320 | + "Could not find resource '{$resource}' in any resource paths.". |
|
| 321 | + "(searched: ".join(", ", $this->searchPaths).")"); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * Given an exception and status code will display the error to the client. |
|
| 326 | - * |
|
| 327 | - * @return int|null |
|
| 328 | - */ |
|
| 329 | - public function handle() |
|
| 330 | - { |
|
| 331 | - $templatePath = $this->getResource('debug.layout.php'); |
|
| 332 | - |
|
| 333 | - $vars = $this->collectionVars(); |
|
| 324 | + /** |
|
| 325 | + * Given an exception and status code will display the error to the client. |
|
| 326 | + * |
|
| 327 | + * @return int|null |
|
| 328 | + */ |
|
| 329 | + public function handle() |
|
| 330 | + { |
|
| 331 | + $templatePath = $this->getResource('debug.layout.php'); |
|
| 332 | + |
|
| 333 | + $vars = $this->collectionVars(); |
|
| 334 | 334 | |
| 335 | - if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
| 335 | + if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
| 336 | 336 | |
| 337 | - $this->template->setVariables($vars); |
|
| 338 | - $this->template->render($templatePath); |
|
| 337 | + $this->template->setVariables($vars); |
|
| 338 | + $this->template->render($templatePath); |
|
| 339 | 339 | |
| 340 | - return MainHandler::QUIT; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * Set the editor to use to open referenced files, by a string identifier or callable |
|
| 345 | - * that will be executed for every file reference. Should return a string. |
|
| 346 | - * |
|
| 347 | - * @example $debug->setEditor(function($file, $line) { return "file:///{$file}"; }); |
|
| 348 | - * @example $debug->setEditor('vscode'); |
|
| 349 | - * |
|
| 350 | - * @param string $editor |
|
| 351 | - * |
|
| 352 | - * @return void |
|
| 353 | - * |
|
| 354 | - * @throws \InvalidArgumentException |
|
| 355 | - */ |
|
| 356 | - public function setEditor($editor) |
|
| 357 | - { |
|
| 358 | - if ( ! is_callable($editor) && ! isset($this->editors[$editor])) { |
|
| 359 | - throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
| 360 | - implode(', ', array_keys($this->editors)) |
|
| 361 | - ); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - $this->editor = $editor; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Given a string file path, and an integer file line, |
|
| 369 | - * executes the editor resolver and returns. |
|
| 370 | - * |
|
| 371 | - * @param string $file |
|
| 372 | - * @param int $line |
|
| 373 | - * |
|
| 374 | - * @return string|bool |
|
| 375 | - * |
|
| 376 | - * @throws \UnexpectedValueException |
|
| 377 | - */ |
|
| 378 | - public function getEditorAtHref($file, $line) |
|
| 379 | - { |
|
| 380 | - $editor = $this->getEditor($file, $line); |
|
| 381 | - |
|
| 382 | - if (empty($editor)) { |
|
| 383 | - return false; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if ( ! isset($editor['url']) || ! is_string($editor['url'])) { |
|
| 387 | - throw new UnexpectedValueException(__METHOD__.'should always resolve to a string or a valid editor array'); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - $editor['url'] = str_replace("%file", rawurldecode($file), $editor['url']); |
|
| 391 | - $editor['url'] = str_replace("%line", rawurldecode($line), $editor['url']); |
|
| 392 | - |
|
| 393 | - return $editor['url']; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * The editor must be a valid callable function/closure. |
|
| 398 | - * |
|
| 399 | - * @param string $file |
|
| 400 | - * @param int $line |
|
| 401 | - * |
|
| 402 | - * @return array |
|
| 403 | - */ |
|
| 404 | - protected function getEditor($file, $line): array |
|
| 405 | - { |
|
| 406 | - if ( ! $this->editor || ( ! is_string($this->editor) && ! is_callable($this->editor))) { |
|
| 407 | - return []; |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - if (is_string($this->editor) && isset($this->editors[$this->editor]) && ! is_callable($this->editors[$this->editor])) { |
|
| 411 | - return ['url' => $this->editors[$this->editor]]; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - if (is_callable($this->editor) || (isset($this->editors[$this->editor]) && is_callable($this->editors[$this->editor]))) { |
|
| 415 | - if (is_callable($this->editor)) { |
|
| 416 | - $callback = call_user_func($this->editor, $file, $line); |
|
| 417 | - } else { |
|
| 418 | - $callback = call_user_func($this->editors[$this->editor], $file, $line); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - if (empty($callback)) { |
|
| 422 | - return []; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if (is_string($callback)) { |
|
| 426 | - return ['url' => $callback]; |
|
| 427 | - } |
|
| 340 | + return MainHandler::QUIT; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * Set the editor to use to open referenced files, by a string identifier or callable |
|
| 345 | + * that will be executed for every file reference. Should return a string. |
|
| 346 | + * |
|
| 347 | + * @example $debug->setEditor(function($file, $line) { return "file:///{$file}"; }); |
|
| 348 | + * @example $debug->setEditor('vscode'); |
|
| 349 | + * |
|
| 350 | + * @param string $editor |
|
| 351 | + * |
|
| 352 | + * @return void |
|
| 353 | + * |
|
| 354 | + * @throws \InvalidArgumentException |
|
| 355 | + */ |
|
| 356 | + public function setEditor($editor) |
|
| 357 | + { |
|
| 358 | + if ( ! is_callable($editor) && ! isset($this->editors[$editor])) { |
|
| 359 | + throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
| 360 | + implode(', ', array_keys($this->editors)) |
|
| 361 | + ); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + $this->editor = $editor; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Given a string file path, and an integer file line, |
|
| 369 | + * executes the editor resolver and returns. |
|
| 370 | + * |
|
| 371 | + * @param string $file |
|
| 372 | + * @param int $line |
|
| 373 | + * |
|
| 374 | + * @return string|bool |
|
| 375 | + * |
|
| 376 | + * @throws \UnexpectedValueException |
|
| 377 | + */ |
|
| 378 | + public function getEditorAtHref($file, $line) |
|
| 379 | + { |
|
| 380 | + $editor = $this->getEditor($file, $line); |
|
| 381 | + |
|
| 382 | + if (empty($editor)) { |
|
| 383 | + return false; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if ( ! isset($editor['url']) || ! is_string($editor['url'])) { |
|
| 387 | + throw new UnexpectedValueException(__METHOD__.'should always resolve to a string or a valid editor array'); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + $editor['url'] = str_replace("%file", rawurldecode($file), $editor['url']); |
|
| 391 | + $editor['url'] = str_replace("%line", rawurldecode($line), $editor['url']); |
|
| 392 | + |
|
| 393 | + return $editor['url']; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * The editor must be a valid callable function/closure. |
|
| 398 | + * |
|
| 399 | + * @param string $file |
|
| 400 | + * @param int $line |
|
| 401 | + * |
|
| 402 | + * @return array |
|
| 403 | + */ |
|
| 404 | + protected function getEditor($file, $line): array |
|
| 405 | + { |
|
| 406 | + if ( ! $this->editor || ( ! is_string($this->editor) && ! is_callable($this->editor))) { |
|
| 407 | + return []; |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + if (is_string($this->editor) && isset($this->editors[$this->editor]) && ! is_callable($this->editors[$this->editor])) { |
|
| 411 | + return ['url' => $this->editors[$this->editor]]; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + if (is_callable($this->editor) || (isset($this->editors[$this->editor]) && is_callable($this->editors[$this->editor]))) { |
|
| 415 | + if (is_callable($this->editor)) { |
|
| 416 | + $callback = call_user_func($this->editor, $file, $line); |
|
| 417 | + } else { |
|
| 418 | + $callback = call_user_func($this->editors[$this->editor], $file, $line); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + if (empty($callback)) { |
|
| 422 | + return []; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if (is_string($callback)) { |
|
| 426 | + return ['url' => $callback]; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - return ['url' => isset($callback['url']) ? $callback['url'] : $callback]; |
|
| 430 | - } |
|
| 429 | + return ['url' => isset($callback['url']) ? $callback['url'] : $callback]; |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | - return []; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * Registered the editor. |
|
| 437 | - * |
|
| 438 | - * @return string |
|
| 439 | - */ |
|
| 440 | - public function getEditorcode(): string |
|
| 441 | - { |
|
| 442 | - return $this->editor; |
|
| 443 | - } |
|
| 432 | + return []; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * Registered the editor. |
|
| 437 | + * |
|
| 438 | + * @return string |
|
| 439 | + */ |
|
| 440 | + public function getEditorcode(): string |
|
| 441 | + { |
|
| 442 | + return $this->editor; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - /** |
|
| 446 | - * Sets the brand of project. |
|
| 447 | - * |
|
| 448 | - * @param string $brand |
|
| 449 | - * |
|
| 450 | - * @return void |
|
| 451 | - */ |
|
| 452 | - public function setBrand($brand): void |
|
| 453 | - { |
|
| 454 | - $this->brand = (string) $brand; |
|
| 455 | - } |
|
| 445 | + /** |
|
| 446 | + * Sets the brand of project. |
|
| 447 | + * |
|
| 448 | + * @param string $brand |
|
| 449 | + * |
|
| 450 | + * @return void |
|
| 451 | + */ |
|
| 452 | + public function setBrand($brand): void |
|
| 453 | + { |
|
| 454 | + $this->brand = (string) $brand; |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | - /** |
|
| 458 | - * Sets the page title web. |
|
| 459 | - * |
|
| 460 | - * @param string $title |
|
| 461 | - * |
|
| 462 | - * @return void |
|
| 463 | - */ |
|
| 464 | - public function setPageTitle($title): void |
|
| 465 | - { |
|
| 466 | - $this->pageTitle = (string) $title; |
|
| 467 | - } |
|
| 457 | + /** |
|
| 458 | + * Sets the page title web. |
|
| 459 | + * |
|
| 460 | + * @param string $title |
|
| 461 | + * |
|
| 462 | + * @return void |
|
| 463 | + */ |
|
| 464 | + public function setPageTitle($title): void |
|
| 465 | + { |
|
| 466 | + $this->pageTitle = (string) $title; |
|
| 467 | + } |
|
| 468 | 468 | } |
| 469 | 469 | \ No newline at end of file |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | $seconds = (int) ($duration - $hours * 60 * 60 - $minutes * 60); |
| 144 | 144 | |
| 145 | 145 | if ($seconds <= 0) { |
| 146 | - return ' ms'; |
|
| 146 | + return ' ms'; |
|
| 147 | 147 | } elseif ($seconds > 0) { |
| 148 | 148 | return ' s'; |
| 149 | 149 | } |
@@ -30,61 +30,61 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class FileMimeType |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * Map of extensions to mime types. |
|
| 35 | - * |
|
| 36 | - * @var array $mimes |
|
| 37 | - */ |
|
| 38 | - public static $mimes = []; |
|
| 33 | + /** |
|
| 34 | + * Map of extensions to mime types. |
|
| 35 | + * |
|
| 36 | + * @var array $mimes |
|
| 37 | + */ |
|
| 38 | + public static $mimes = []; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Constructor with an optional verification that the path is |
|
| 42 | - * really a mimes. |
|
| 43 | - * |
|
| 44 | - * @return mixed |
|
| 45 | - */ |
|
| 46 | - public function __construct() |
|
| 47 | - { |
|
| 48 | - static::$mimes = (array) require CON_PATH.'mimes.php'; |
|
| 49 | - } |
|
| 40 | + /** |
|
| 41 | + * Constructor with an optional verification that the path is |
|
| 42 | + * really a mimes. |
|
| 43 | + * |
|
| 44 | + * @return mixed |
|
| 45 | + */ |
|
| 46 | + public function __construct() |
|
| 47 | + { |
|
| 48 | + static::$mimes = (array) require CON_PATH.'mimes.php'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Attempts to determine the best mime type for the given file extension. |
|
| 53 | - * |
|
| 54 | - * @param string $extension |
|
| 55 | - * |
|
| 56 | - * @return string|null The mime type found, or none if unable to determine |
|
| 57 | - */ |
|
| 58 | - public static function guessTypeFromExtension($extension) |
|
| 59 | - { |
|
| 60 | - $extension = trim(strtolower($extension), '. '); |
|
| 51 | + /** |
|
| 52 | + * Attempts to determine the best mime type for the given file extension. |
|
| 53 | + * |
|
| 54 | + * @param string $extension |
|
| 55 | + * |
|
| 56 | + * @return string|null The mime type found, or none if unable to determine |
|
| 57 | + */ |
|
| 58 | + public static function guessTypeFromExtension($extension) |
|
| 59 | + { |
|
| 60 | + $extension = trim(strtolower($extension), '. '); |
|
| 61 | 61 | |
| 62 | - if ( ! array_key_exists($extension, static::$mimes)) { |
|
| 63 | - return null; |
|
| 64 | - } |
|
| 62 | + if ( ! array_key_exists($extension, static::$mimes)) { |
|
| 63 | + return null; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension]; |
|
| 67 | - } |
|
| 66 | + return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension]; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Attempts to determine the best file extension for a given mime type. |
|
| 71 | - * |
|
| 72 | - * @param string $type |
|
| 73 | - * |
|
| 74 | - * @return string|null The extension determined, or null if unable to match |
|
| 75 | - */ |
|
| 76 | - public static function guessExtensionFromType($type) |
|
| 77 | - { |
|
| 78 | - $type = trim(strtolower($type), '. '); |
|
| 69 | + /** |
|
| 70 | + * Attempts to determine the best file extension for a given mime type. |
|
| 71 | + * |
|
| 72 | + * @param string $type |
|
| 73 | + * |
|
| 74 | + * @return string|null The extension determined, or null if unable to match |
|
| 75 | + */ |
|
| 76 | + public static function guessExtensionFromType($type) |
|
| 77 | + { |
|
| 78 | + $type = trim(strtolower($type), '. '); |
|
| 79 | 79 | |
| 80 | - foreach (static::$mimes as $ext => $types) { |
|
| 81 | - if (is_string($types) && $types == $type) { |
|
| 82 | - return $ext; |
|
| 83 | - } elseif (is_array($types) && in_array($type, $types)) { |
|
| 84 | - return $ext; |
|
| 85 | - } |
|
| 86 | - } |
|
| 80 | + foreach (static::$mimes as $ext => $types) { |
|
| 81 | + if (is_string($types) && $types == $type) { |
|
| 82 | + return $ext; |
|
| 83 | + } elseif (is_array($types) && in_array($type, $types)) { |
|
| 84 | + return $ext; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - return null; |
|
| 89 | - } |
|
| 88 | + return null; |
|
| 89 | + } |
|
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -176,7 +176,7 @@ |
||
| 176 | 176 | $connection->setEventDispatcher($this->app['events']); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $connection->setReconnector(function ($connection) { |
|
| 179 | + $connection->setReconnector(function($connection) { |
|
| 180 | 180 | $this->reconnect($connection->getName()); |
| 181 | 181 | }); |
| 182 | 182 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->rawTags[0], $this->rawTags[1]); |
| 73 | 73 | |
| 74 | - $callback = function ($matches) { |
|
| 74 | + $callback = function($matches) { |
|
| 75 | 75 | $whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3]; |
| 76 | 76 | |
| 77 | 77 | return $matches[1] ? substr($matches[0], 1) : "<?php echo {$matches[2]}; ?>{$whitespace}"; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->contentTags[0], $this->contentTags[1]); |
| 93 | 93 | |
| 94 | - $callback = function ($matches) { |
|
| 94 | + $callback = function($matches) { |
|
| 95 | 95 | $whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3]; |
| 96 | 96 | |
| 97 | 97 | $wrapped = sprintf($this->echoFormat, $matches[2]); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->escapedTags[0], $this->escapedTags[1]); |
| 115 | 115 | |
| 116 | - $callback = function ($matches) { |
|
| 116 | + $callback = function($matches) { |
|
| 117 | 117 | $whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3]; |
| 118 | 118 | |
| 119 | 119 | return $matches[1] ? $matches[0] : "<?php echo e({$matches[2]}); ?>{$whitespace}"; |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | |
| 165 | 165 | foreach ($transitions as $transition) { |
| 166 | 166 | if ($transition['time'] > $this->format('U')) { |
| 167 | - $dayLightSaving = (bool) $transition['isdst'] ?? $dayLightSaving; |
|
| 167 | + $dayLightSaving = (bool) $transition['isdst'] ?? $dayLightSaving; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public function register() |
| 55 | 55 | { |
| 56 | - $this->booting(function () { |
|
| 56 | + $this->booting(function() { |
|
| 57 | 57 | $events = $this->listens(); |
| 58 | 58 | |
| 59 | 59 | foreach ((array) $events as $event => $listeners) { |
@@ -33,35 +33,35 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class PostTooLargeHttpException extends HttpException |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * Get the HTTP status code. |
|
| 38 | - * |
|
| 39 | - * @var int $code |
|
| 40 | - */ |
|
| 41 | - protected $code = 413; |
|
| 36 | + /** |
|
| 37 | + * Get the HTTP status code. |
|
| 38 | + * |
|
| 39 | + * @var int $code |
|
| 40 | + */ |
|
| 41 | + protected $code = 413; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Initialize constructor. |
|
| 45 | - * |
|
| 46 | - * @param string|null $message |
|
| 47 | - * @param \Throwable|null $previous |
|
| 48 | - * @param int $code |
|
| 49 | - * @param array $headers |
|
| 50 | - * |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function __construct( |
|
| 54 | - string $message = null, |
|
| 55 | - Throwable $previous = null, |
|
| 56 | - int $code = 0, |
|
| 57 | - array $headers = [] |
|
| 58 | - ) { |
|
| 43 | + /** |
|
| 44 | + * Initialize constructor. |
|
| 45 | + * |
|
| 46 | + * @param string|null $message |
|
| 47 | + * @param \Throwable|null $previous |
|
| 48 | + * @param int $code |
|
| 49 | + * @param array $headers |
|
| 50 | + * |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function __construct( |
|
| 54 | + string $message = null, |
|
| 55 | + Throwable $previous = null, |
|
| 56 | + int $code = 0, |
|
| 57 | + array $headers = [] |
|
| 58 | + ) { |
|
| 59 | 59 | parent::__construct( |
| 60 | - $this->code, |
|
| 61 | - $message, |
|
| 62 | - $previous, |
|
| 63 | - $headers, |
|
| 64 | - $code |
|
| 65 | - ); |
|
| 66 | - } |
|
| 60 | + $this->code, |
|
| 61 | + $message, |
|
| 62 | + $previous, |
|
| 63 | + $headers, |
|
| 64 | + $code |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | \ No newline at end of file |
@@ -34,143 +34,143 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class Configure implements ArrayAccess, ConfigureContract |
| 36 | 36 | { |
| 37 | - /** |
|
| 38 | - * Currently registered routes. |
|
| 39 | - * |
|
| 40 | - * @var array $vars |
|
| 41 | - */ |
|
| 42 | - protected $vars = []; |
|
| 37 | + /** |
|
| 38 | + * Currently registered routes. |
|
| 39 | + * |
|
| 40 | + * @var array $vars |
|
| 41 | + */ |
|
| 42 | + protected $vars = []; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Determine if the given configuration value exists. |
|
| 46 | - * |
|
| 47 | - * @param string $key |
|
| 48 | - * |
|
| 49 | - * @return bool |
|
| 50 | - */ |
|
| 51 | - public function has(string $key): bool |
|
| 52 | - { |
|
| 53 | - return Arr::has($this->vars, $key); |
|
| 54 | - } |
|
| 44 | + /** |
|
| 45 | + * Determine if the given configuration value exists. |
|
| 46 | + * |
|
| 47 | + * @param string $key |
|
| 48 | + * |
|
| 49 | + * @return bool |
|
| 50 | + */ |
|
| 51 | + public function has(string $key): bool |
|
| 52 | + { |
|
| 53 | + return Arr::has($this->vars, $key); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Returns a (dot notated) config setting. |
|
| 58 | - * |
|
| 59 | - * @param string $key The dot-notated key or array of keys |
|
| 60 | - * @param mixed $default The default value |
|
| 61 | - * |
|
| 62 | - * @return mixed |
|
| 63 | - */ |
|
| 64 | - public function get(string $key, mixed $default = null): mixed |
|
| 65 | - { |
|
| 66 | - $keys = explode('.', $key); |
|
| 56 | + /** |
|
| 57 | + * Returns a (dot notated) config setting. |
|
| 58 | + * |
|
| 59 | + * @param string $key The dot-notated key or array of keys |
|
| 60 | + * @param mixed $default The default value |
|
| 61 | + * |
|
| 62 | + * @return mixed |
|
| 63 | + */ |
|
| 64 | + public function get(string $key, mixed $default = null): mixed |
|
| 65 | + { |
|
| 66 | + $keys = explode('.', $key); |
|
| 67 | 67 | |
| 68 | - if ( ! array_key_exists($file = headItem($keys), $this->vars)) { |
|
| 69 | - foreach ([configPath().DIRECTORY_SEPARATOR] as $paths) { |
|
| 70 | - if (is_readable($path = $paths.$file.'.php')) { |
|
| 71 | - $this->vars[$file] = require $path; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 68 | + if ( ! array_key_exists($file = headItem($keys), $this->vars)) { |
|
| 69 | + foreach ([configPath().DIRECTORY_SEPARATOR] as $paths) { |
|
| 70 | + if (is_readable($path = $paths.$file.'.php')) { |
|
| 71 | + $this->vars[$file] = require $path; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return Arr::get($this->vars, $key, $default); |
|
| 77 | - } |
|
| 76 | + return Arr::get($this->vars, $key, $default); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Sets a value in the config array. |
|
| 81 | - * |
|
| 82 | - * @param string $key The dot-notated key or array of keys |
|
| 83 | - * @param mixed $value The default value |
|
| 84 | - * |
|
| 85 | - * @return mixed |
|
| 86 | - */ |
|
| 87 | - public function set(string $key, mixed $value = null): mixed |
|
| 88 | - { |
|
| 89 | - $keys = is_array($key) ? $key : [$key => $value]; |
|
| 79 | + /** |
|
| 80 | + * Sets a value in the config array. |
|
| 81 | + * |
|
| 82 | + * @param string $key The dot-notated key or array of keys |
|
| 83 | + * @param mixed $value The default value |
|
| 84 | + * |
|
| 85 | + * @return mixed |
|
| 86 | + */ |
|
| 87 | + public function set(string $key, mixed $value = null): mixed |
|
| 88 | + { |
|
| 89 | + $keys = is_array($key) ? $key : [$key => $value]; |
|
| 90 | 90 | |
| 91 | - foreach ($keys as $key => $value) { |
|
| 92 | - Arr::set($this->vars, $key, $value); |
|
| 93 | - } |
|
| 94 | - } |
|
| 91 | + foreach ($keys as $key => $value) { |
|
| 92 | + Arr::set($this->vars, $key, $value); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Deletes a (dot notated) config item. |
|
| 98 | - * |
|
| 99 | - * @param string $key A (dot notated) config key |
|
| 100 | - * |
|
| 101 | - * @return void |
|
| 102 | - */ |
|
| 103 | - public function erase(string $key): void |
|
| 104 | - { |
|
| 105 | - if (isset($this->vars[$key])) { |
|
| 106 | - unset($this->vars[$key]); |
|
| 107 | - } |
|
| 96 | + /** |
|
| 97 | + * Deletes a (dot notated) config item. |
|
| 98 | + * |
|
| 99 | + * @param string $key A (dot notated) config key |
|
| 100 | + * |
|
| 101 | + * @return void |
|
| 102 | + */ |
|
| 103 | + public function erase(string $key): void |
|
| 104 | + { |
|
| 105 | + if (isset($this->vars[$key])) { |
|
| 106 | + unset($this->vars[$key]); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - Arr::erase($this->vars, $key); |
|
| 110 | - } |
|
| 109 | + Arr::erase($this->vars, $key); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Get all of the configuration items for the application. |
|
| 114 | - * |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function all(): array |
|
| 118 | - { |
|
| 119 | - return $this->vars; |
|
| 120 | - } |
|
| 112 | + /** |
|
| 113 | + * Get all of the configuration items for the application. |
|
| 114 | + * |
|
| 115 | + * @return array |
|
| 116 | + */ |
|
| 117 | + public function all(): array |
|
| 118 | + { |
|
| 119 | + return $this->vars; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /* |
|
| 122 | + /* |
|
| 123 | 123 | |----------------------------------------------------------------- |
| 124 | 124 | | ArrayAccess Methods |
| 125 | 125 | |----------------------------------------------------------------- |
| 126 | 126 | */ |
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Determine if the given configuration option exists. |
|
| 130 | - * |
|
| 131 | - * @param string $key |
|
| 132 | - * |
|
| 133 | - * @return bool |
|
| 134 | - */ |
|
| 135 | - public function offsetExists($key): bool |
|
| 136 | - { |
|
| 137 | - return $this->has($key); |
|
| 138 | - } |
|
| 128 | + /** |
|
| 129 | + * Determine if the given configuration option exists. |
|
| 130 | + * |
|
| 131 | + * @param string $key |
|
| 132 | + * |
|
| 133 | + * @return bool |
|
| 134 | + */ |
|
| 135 | + public function offsetExists($key): bool |
|
| 136 | + { |
|
| 137 | + return $this->has($key); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Get a configuration option. |
|
| 142 | - * |
|
| 143 | - * @param string $key |
|
| 144 | - * |
|
| 145 | - * @return mixed |
|
| 146 | - */ |
|
| 147 | - public function offsetGet($key) |
|
| 148 | - { |
|
| 149 | - return $this->get($key); |
|
| 150 | - } |
|
| 140 | + /** |
|
| 141 | + * Get a configuration option. |
|
| 142 | + * |
|
| 143 | + * @param string $key |
|
| 144 | + * |
|
| 145 | + * @return mixed |
|
| 146 | + */ |
|
| 147 | + public function offsetGet($key) |
|
| 148 | + { |
|
| 149 | + return $this->get($key); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Set a configuration option. |
|
| 154 | - * |
|
| 155 | - * @param string $key |
|
| 156 | - * @param mixed $value |
|
| 157 | - * |
|
| 158 | - * @return void |
|
| 159 | - */ |
|
| 160 | - public function offsetSet($key, $value): void |
|
| 161 | - { |
|
| 162 | - $this->set($key, $value); |
|
| 163 | - } |
|
| 152 | + /** |
|
| 153 | + * Set a configuration option. |
|
| 154 | + * |
|
| 155 | + * @param string $key |
|
| 156 | + * @param mixed $value |
|
| 157 | + * |
|
| 158 | + * @return void |
|
| 159 | + */ |
|
| 160 | + public function offsetSet($key, $value): void |
|
| 161 | + { |
|
| 162 | + $this->set($key, $value); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Unset a configuration option. |
|
| 167 | - * |
|
| 168 | - * @param string $key |
|
| 169 | - * |
|
| 170 | - * @return void |
|
| 171 | - */ |
|
| 172 | - public function offsetUnset($key): void |
|
| 173 | - { |
|
| 174 | - $this->set($key, null); |
|
| 175 | - } |
|
| 165 | + /** |
|
| 166 | + * Unset a configuration option. |
|
| 167 | + * |
|
| 168 | + * @param string $key |
|
| 169 | + * |
|
| 170 | + * @return void |
|
| 171 | + */ |
|
| 172 | + public function offsetUnset($key): void |
|
| 173 | + { |
|
| 174 | + $this->set($key, null); |
|
| 175 | + } |
|
| 176 | 176 | } |
| 177 | 177 | \ No newline at end of file |