@@ -154,8 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function updateTotalPages(): Paginator |
| 156 | 156 | { |
| 157 | - $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : |
|
| 158 | - (int)ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
| 157 | + $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : (int) ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
| 159 | 158 | return $this; |
| 160 | 159 | } |
| 161 | 160 | |
@@ -219,8 +218,7 @@ discard block |
||
| 219 | 218 | protected function getPrevPage(): Page |
| 220 | 219 | { |
| 221 | 220 | return $this->nCurrentPage <= 1 ? |
| 222 | - new Page('disabled', $this->sPreviousText, 0) : |
|
| 223 | - new Page('enabled', $this->sPreviousText, $this->nCurrentPage - 1); |
|
| 221 | + new Page('disabled', $this->sPreviousText, 0) : new Page('enabled', $this->sPreviousText, $this->nCurrentPage - 1); |
|
| 224 | 222 | } |
| 225 | 223 | |
| 226 | 224 | /** |
@@ -231,8 +229,7 @@ discard block |
||
| 231 | 229 | protected function getNextPage(): Page |
| 232 | 230 | { |
| 233 | 231 | return $this->nCurrentPage >= $this->nTotalPages ? |
| 234 | - new Page('disabled', $this->sNextText, 0) : |
|
| 235 | - new Page('enabled', $this->sNextText, $this->nCurrentPage + 1); |
|
| 232 | + new Page('disabled', $this->sNextText, 0) : new Page('enabled', $this->sNextText, $this->nCurrentPage + 1); |
|
| 236 | 233 | } |
| 237 | 234 | |
| 238 | 235 | /** |
@@ -244,7 +241,7 @@ discard block |
||
| 244 | 241 | */ |
| 245 | 242 | protected function getPage(int $nNumber): Page |
| 246 | 243 | { |
| 247 | - if($nNumber < 1) |
|
| 244 | + if ($nNumber < 1) |
|
| 248 | 245 | { |
| 249 | 246 | return new Page('disabled', $this->sEllipsysText, 0); |
| 250 | 247 | } |
@@ -263,9 +260,9 @@ discard block |
||
| 263 | 260 | { |
| 264 | 261 | $aPageNumbers = []; |
| 265 | 262 | |
| 266 | - if($this->nTotalPages <= $this->nMaxPages) |
|
| 263 | + if ($this->nTotalPages <= $this->nMaxPages) |
|
| 267 | 264 | { |
| 268 | - for($i = 0; $i < $this->nTotalPages; $i++) |
|
| 265 | + for ($i = 0; $i < $this->nTotalPages; $i++) |
|
| 269 | 266 | { |
| 270 | 267 | $aPageNumbers[] = $i + 1; |
| 271 | 268 | } |
@@ -274,11 +271,11 @@ discard block |
||
| 274 | 271 | } |
| 275 | 272 | |
| 276 | 273 | // Determine the sliding range, centered around the current page. |
| 277 | - $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
| 274 | + $nNumAdjacents = (int) floor(($this->nMaxPages - 4) / 2); |
|
| 278 | 275 | |
| 279 | 276 | $nSlidingStart = 1; |
| 280 | 277 | $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nCurrentPage; |
| 281 | - if($nSlidingEndOffset < 0) |
|
| 278 | + if ($nSlidingEndOffset < 0) |
|
| 282 | 279 | { |
| 283 | 280 | $nSlidingStart = $this->nCurrentPage - $nNumAdjacents; |
| 284 | 281 | $nSlidingEndOffset = 0; |
@@ -286,23 +283,23 @@ discard block |
||
| 286 | 283 | |
| 287 | 284 | $nSlidingEnd = $this->nTotalPages; |
| 288 | 285 | $nSlidingStartOffset = $this->nCurrentPage + $nNumAdjacents + 2 - $this->nTotalPages; |
| 289 | - if($nSlidingStartOffset < 0) |
|
| 286 | + if ($nSlidingStartOffset < 0) |
|
| 290 | 287 | { |
| 291 | 288 | $nSlidingEnd = $this->nCurrentPage + $nNumAdjacents; |
| 292 | 289 | $nSlidingStartOffset = 0; |
| 293 | 290 | } |
| 294 | 291 | |
| 295 | 292 | // Build the list of page numbers. |
| 296 | - if($nSlidingStart > 1) |
|
| 293 | + if ($nSlidingStart > 1) |
|
| 297 | 294 | { |
| 298 | 295 | $aPageNumbers[] = 1; |
| 299 | 296 | $aPageNumbers[] = 0; // Ellipsys; |
| 300 | 297 | } |
| 301 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 298 | + for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
| 302 | 299 | { |
| 303 | 300 | $aPageNumbers[] = $i; |
| 304 | 301 | } |
| 305 | - if($nSlidingEnd < $this->nTotalPages) |
|
| 302 | + if ($nSlidingEnd < $this->nTotalPages) |
|
| 306 | 303 | { |
| 307 | 304 | $aPageNumbers[] = 0; // Ellipsys; |
| 308 | 305 | $aPageNumbers[] = $this->nTotalPages; |
@@ -318,7 +315,7 @@ discard block |
||
| 318 | 315 | */ |
| 319 | 316 | public function pages(): array |
| 320 | 317 | { |
| 321 | - if($this->nTotalPages < 2) |
|
| 318 | + if ($this->nTotalPages < 2) |
|
| 322 | 319 | { |
| 323 | 320 | return []; |
| 324 | 321 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | - public function addCommand(string $sName, array|JsonSerializable $aOptions) |
|
| 74 | + public function addCommand(string $sName, array | JsonSerializable $aOptions) |
|
| 75 | 75 | { |
| 76 | 76 | $this->xResponse->addPluginCommand($this, $sName, $aOptions); |
| 77 | 77 | } |
@@ -17,14 +17,14 @@ |
||
| 17 | 17 | |
| 18 | 18 | trait HtmlDomTrait |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Add a response command to the array of commands that will be sent to the browser |
|
| 22 | - * |
|
| 23 | - * @param string $sName The command name |
|
| 24 | - * @param array|JsonSerializable $aOptions The command options |
|
| 25 | - * |
|
| 26 | - * @return ResponseInterface |
|
| 27 | - */ |
|
| 20 | + /** |
|
| 21 | + * Add a response command to the array of commands that will be sent to the browser |
|
| 22 | + * |
|
| 23 | + * @param string $sName The command name |
|
| 24 | + * @param array|JsonSerializable $aOptions The command options |
|
| 25 | + * |
|
| 26 | + * @return ResponseInterface |
|
| 27 | + */ |
|
| 28 | 28 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * |
| 26 | 26 | * @return ResponseInterface |
| 27 | 27 | */ |
| 28 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
| 28 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Convert to string |
@@ -20,14 +20,14 @@ |
||
| 20 | 20 | |
| 21 | 21 | trait ScriptTrait |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Add a response command to the array of commands that will be sent to the browser |
|
| 25 | - * |
|
| 26 | - * @param string $sName The command name |
|
| 27 | - * @param array|JsonSerializable $aOptions The command options |
|
| 28 | - * |
|
| 29 | - * @return ResponseInterface |
|
| 30 | - */ |
|
| 23 | + /** |
|
| 24 | + * Add a response command to the array of commands that will be sent to the browser |
|
| 25 | + * |
|
| 26 | + * @param string $sName The command name |
|
| 27 | + * @param array|JsonSerializable $aOptions The command options |
|
| 28 | + * |
|
| 29 | + * @return ResponseInterface |
|
| 30 | + */ |
|
| 31 | 31 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return ResponseInterface |
| 34 | 34 | */ |
| 35 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
| 35 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Convert to string |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $aArgs = func_get_args(); |
| 61 | 61 | array_shift($aArgs); |
| 62 | - return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
| 62 | + return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $xResponse = jaxon()->newResponse(); |
| 80 | 80 | $fCalls($xResponse); |
| 81 | - if(($nCommandCount = $xResponse->getCommandCount()) > 0) |
|
| 81 | + if (($nCommandCount = $xResponse->getCommandCount()) > 0) |
|
| 82 | 82 | { |
| 83 | 83 | $this->addCommand('script.confirm', [ |
| 84 | 84 | 'count' => $nCommandCount, |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * @return ResponseInterface |
| 74 | 74 | */ |
| 75 | 75 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
| 76 | - array|JsonSerializable $aOptions): ResponseInterface; |
|
| 76 | + array | JsonSerializable $aOptions): ResponseInterface; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Convert this response to a PSR7 response object |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function initDataBag() |
| 41 | 41 | { |
| 42 | - if($this->xDataBag !== null) |
|
| 42 | + if ($this->xDataBag !== null) |
|
| 43 | 43 | { |
| 44 | 44 | return; |
| 45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | $aBody = $xRequest->getParsedBody(); |
| 49 | 49 | $aParams = $xRequest->getQueryParams(); |
| 50 | 50 | $aData = is_array($aBody) ? |
| 51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
| 52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
| 51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
| 53 | 52 | $this->xDataBag = new DataBag($aData); |
| 54 | 53 | } |
| 55 | 54 | |
@@ -70,8 +69,7 @@ discard block |
||
| 70 | 69 | { |
| 71 | 70 | // Todo: clean input data. |
| 72 | 71 | return is_string($xData) ? |
| 73 | - (json_decode($xData, true) ?: []) : |
|
| 74 | - (is_array($xData) ? $xData : []); |
|
| 72 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
| 75 | 73 | } |
| 76 | 74 | |
| 77 | 75 | /** |
@@ -89,7 +87,7 @@ discard block |
||
| 89 | 87 | public function writeCommand() |
| 90 | 88 | { |
| 91 | 89 | $this->initDataBag(); |
| 92 | - if($this->xDataBag->touched()) |
|
| 90 | + if ($this->xDataBag->touched()) |
|
| 93 | 91 | { |
| 94 | 92 | $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
| 95 | 93 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | private function checkDirectory(string $sDirectory): string |
| 81 | 81 | { |
| 82 | 82 | $sDirectory = rtrim(trim($sDirectory), '/\\'); |
| 83 | - if(!is_dir($sDirectory)) |
|
| 83 | + if (!is_dir($sDirectory)) |
|
| 84 | 84 | { |
| 85 | 85 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 86 | 86 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function checkOptions(string $sCallable, $xOptions): array |
| 95 | 95 | { |
| 96 | - if(is_string($xOptions)) |
|
| 96 | + if (is_string($xOptions)) |
|
| 97 | 97 | { |
| 98 | 98 | $xOptions = ['namespace' => $xOptions]; |
| 99 | 99 | } |
| 100 | - if(!is_array($xOptions)) |
|
| 100 | + if (!is_array($xOptions)) |
|
| 101 | 101 | { |
| 102 | 102 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 103 | 103 | } |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | $xOptions['directory'] = $this->checkDirectory($sCallable); |
| 106 | 106 | // Check the namespace |
| 107 | 107 | $sNamespace = $xOptions['namespace'] ?? ''; |
| 108 | - if(!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
| 108 | + if (!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
| 109 | 109 | { |
| 110 | 110 | $xOptions['namespace'] = ''; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Change the keys in $xOptions to have "\" as separator |
| 114 | 114 | $_aOptions = []; |
| 115 | - foreach($xOptions as $sName => $aOption) |
|
| 115 | + foreach ($xOptions as $sName => $aOption) |
|
| 116 | 116 | { |
| 117 | 117 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
| 118 | 118 | $_aOptions[$sName] = $aOption; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function register(string $sType, string $sCallable, array $aOptions): bool |
| 127 | 127 | { |
| 128 | - if(($aOptions['namespace'])) |
|
| 128 | + if (($aOptions['namespace'])) |
|
| 129 | 129 | { |
| 130 | 130 | $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions); |
| 131 | 131 | return true; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function str($xData): string |
| 128 | 128 | { |
| 129 | - return trim((string)$xData, " \t\n"); |
|
| 129 | + return trim((string) $xData, " \t\n"); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | public function toPsr(): PsrResponseInterface |
| 186 | 186 | { |
| 187 | 187 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
| 188 | - if($this->xRequest->getMethod() === 'GET') |
|
| 188 | + if ($this->xRequest->getMethod() === 'GET') |
|
| 189 | 189 | { |
| 190 | 190 | $xPsrResponse = $xPsrResponse |
| 191 | 191 | ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') |
@@ -69,8 +69,7 @@ discard block |
||
| 69 | 69 | public function appendCommands(array $aCommands, bool $bBefore = false) |
| 70 | 70 | { |
| 71 | 71 | $this->aCommands = ($bBefore) ? |
| 72 | - array_merge($aCommands, $this->aCommands) : |
|
| 73 | - array_merge($this->aCommands, $aCommands); |
|
| 72 | + array_merge($aCommands, $this->aCommands) : array_merge($this->aCommands, $aCommands); |
|
| 74 | 73 | } |
| 75 | 74 | |
| 76 | 75 | /** |
@@ -94,7 +93,7 @@ discard block |
||
| 94 | 93 | * |
| 95 | 94 | * @return ResponseInterface |
| 96 | 95 | */ |
| 97 | - public function addCommand(string $sName, array|JsonSerializable $aArgs): ResponseInterface |
|
| 96 | + public function addCommand(string $sName, array | JsonSerializable $aArgs): ResponseInterface |
|
| 98 | 97 | { |
| 99 | 98 | $this->aCommands[] = [ |
| 100 | 99 | 'name' => $this->str($sName), |
@@ -113,7 +112,7 @@ discard block |
||
| 113 | 112 | * @return ResponseInterface |
| 114 | 113 | */ |
| 115 | 114 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
| 116 | - array|JsonSerializable $aArgs): ResponseInterface |
|
| 115 | + array | JsonSerializable $aArgs): ResponseInterface |
|
| 117 | 116 | { |
| 118 | 117 | $this->aCommands[] = [ |
| 119 | 118 | 'name' => $this->str($sName), |
@@ -132,10 +131,10 @@ discard block |
||
| 132 | 131 | * |
| 133 | 132 | * @return ResponseInterface |
| 134 | 133 | */ |
| 135 | - protected function _addCommand(string $sName, array|JsonSerializable $aArgs, |
|
| 134 | + protected function _addCommand(string $sName, array | JsonSerializable $aArgs, |
|
| 136 | 135 | bool $bRemoveEmpty = false): ResponseInterface |
| 137 | 136 | { |
| 138 | - if($bRemoveEmpty) |
|
| 137 | + if ($bRemoveEmpty) |
|
| 139 | 138 | { |
| 140 | 139 | $aArgs = array_filter($aArgs, function($xArg) { |
| 141 | 140 | return $xArg === ''; |