We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -438,10 +438,10 @@ |
||
| 438 | 438 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - /** |
|
| 442 | - * Tests if paginator aborts when 0 is provided as key. |
|
| 443 | - * |
|
| 444 | - */ |
|
| 441 | + /** |
|
| 442 | + * Tests if paginator aborts when 0 is provided as key. |
|
| 443 | + * |
|
| 444 | + */ |
|
| 445 | 445 | public function testCrudPanelPaginatorWithZeroAsOption() |
| 446 | 446 | { |
| 447 | 447 | $this->crudPanel->setModel(User::class); |
@@ -429,7 +429,7 @@ |
||
| 429 | 429 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
| 430 | 430 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
| 431 | 431 | |
| 432 | - $this->crudPanel->setPageLengthMenu([-1 , 1]); |
|
| 432 | + $this->crudPanel->setPageLengthMenu([-1, 1]); |
|
| 433 | 433 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
| 434 | 434 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
| 435 | 435 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $id = $this->getCurrentEntryId(); |
| 40 | 40 | |
| 41 | - if (! $id) { |
|
| 41 | + if (!$id) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function getEntry($id) |
| 56 | 56 | { |
| 57 | - if (! $this->entry) { |
|
| 57 | + if (!$this->entry) { |
|
| 58 | 58 | $this->entry = $this->model->findOrFail($id); |
| 59 | 59 | $this->entry = $this->entry->withFakes(); |
| 60 | 60 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function setDefaultPageLength($value) |
| 186 | 186 | { |
| 187 | - if($value !== 0) { |
|
| 187 | + if ($value !== 0) { |
|
| 188 | 188 | $this->setOperationSetting('defaultPageLength', $value); |
| 189 | - }else{ |
|
| 189 | + } else { |
|
| 190 | 190 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | if ($position !== false) { |
| 218 | 218 | array_unshift($values, $this->getDefaultPageLength()); |
| 219 | 219 | array_unshift($labels, $labels[$position]); |
| 220 | - }else{ |
|
| 220 | + } else { |
|
| 221 | 221 | // if it's not in array we add it as the first element |
| 222 | 222 | array_unshift($values, $this->getDefaultPageLength()); |
| 223 | 223 | array_unshift($labels, $this->getDefaultPageLength()); |
@@ -239,27 +239,27 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function setPageLengthMenu($menu) |
| 241 | 241 | { |
| 242 | - if(is_array($menu)) { |
|
| 242 | + if (is_array($menu)) { |
|
| 243 | 243 | // start checking $menu integrity |
| 244 | - if(count($menu) !== count($menu, COUNT_RECURSIVE)) { |
|
| 244 | + if (count($menu) !== count($menu, COUNT_RECURSIVE)) { |
|
| 245 | 245 | // developer defined as setPageLengthMenu([[50, 100, 300]]) or setPageLengthMenu([[50, 100, 300],['f','h','t']]) |
| 246 | 246 | // we will apply the same labels as the values to the menu if developer didn't |
| 247 | - if(!in_array(0, $menu[0])) { |
|
| 248 | - if (! isset($menu[1]) || ! is_array($menu[1])) { |
|
| 247 | + if (!in_array(0, $menu[0])) { |
|
| 248 | + if (!isset($menu[1]) || !is_array($menu[1])) { |
|
| 249 | 249 | $menu[1] = $menu[0]; |
| 250 | 250 | } |
| 251 | - }else{ |
|
| 251 | + } else { |
|
| 252 | 252 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 253 | 253 | } |
| 254 | - }else{ |
|
| 254 | + } else { |
|
| 255 | 255 | // developer defined setPageLengthMenu([10 => 'f', 100 => 'h', 300 => 't']) OR setPageLengthMenu([50, 100, 300]) |
| 256 | 256 | $menu = $this->buildPageLengthMenuFromArray($menu); |
| 257 | 257 | } |
| 258 | - }else{ |
|
| 258 | + } else { |
|
| 259 | 259 | // developer added only a single value setPageLengthMenu(10) |
| 260 | - if($menu !== 0) { |
|
| 260 | + if ($menu !== 0) { |
|
| 261 | 261 | $menu = [[$menu], [$menu]]; |
| 262 | - }else{ |
|
| 262 | + } else { |
|
| 263 | 263 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -279,20 +279,20 @@ discard block |
||
| 279 | 279 | private function buildPageLengthMenuFromArray($menu) { |
| 280 | 280 | // check if the values of the array are strings, in case developer defined: |
| 281 | 281 | // setPageLengthMenu([0 => 'f', 100 => 'h', 300 => 't']) |
| 282 | - if(count(array_filter(array_values($menu), 'is_string')) > 0) { |
|
| 282 | + if (count(array_filter(array_values($menu), 'is_string')) > 0) { |
|
| 283 | 283 | $values = array_keys($menu); |
| 284 | 284 | $labels = array_values($menu); |
| 285 | 285 | |
| 286 | - if(!in_array(0, $values)) { |
|
| 286 | + if (!in_array(0, $values)) { |
|
| 287 | 287 | return [$values, $labels]; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 291 | 291 | |
| 292 | - }else{ |
|
| 292 | + } else { |
|
| 293 | 293 | // developer defined length as setPageLengthMenu([50, 100, 300]) |
| 294 | 294 | // we will use the same values as labels |
| 295 | - if(!in_array(0, $menu)) { |
|
| 295 | + if (!in_array(0, $menu)) { |
|
| 296 | 296 | return [$menu, $menu]; |
| 297 | 297 | } |
| 298 | 298 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | if($value !== 0) { |
| 188 | 188 | $this->setOperationSetting('defaultPageLength', $value); |
| 189 | - }else{ |
|
| 189 | + } else{ |
|
| 190 | 190 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | if ($position !== false) { |
| 218 | 218 | array_unshift($values, $this->getDefaultPageLength()); |
| 219 | 219 | array_unshift($labels, $labels[$position]); |
| 220 | - }else{ |
|
| 220 | + } else{ |
|
| 221 | 221 | // if it's not in array we add it as the first element |
| 222 | 222 | array_unshift($values, $this->getDefaultPageLength()); |
| 223 | 223 | array_unshift($labels, $this->getDefaultPageLength()); |
@@ -248,18 +248,18 @@ discard block |
||
| 248 | 248 | if (! isset($menu[1]) || ! is_array($menu[1])) { |
| 249 | 249 | $menu[1] = $menu[0]; |
| 250 | 250 | } |
| 251 | - }else{ |
|
| 251 | + } else{ |
|
| 252 | 252 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 253 | 253 | } |
| 254 | - }else{ |
|
| 254 | + } else{ |
|
| 255 | 255 | // developer defined setPageLengthMenu([10 => 'f', 100 => 'h', 300 => 't']) OR setPageLengthMenu([50, 100, 300]) |
| 256 | 256 | $menu = $this->buildPageLengthMenuFromArray($menu); |
| 257 | 257 | } |
| 258 | - }else{ |
|
| 258 | + } else{ |
|
| 259 | 259 | // developer added only a single value setPageLengthMenu(10) |
| 260 | 260 | if($menu !== 0) { |
| 261 | 261 | $menu = [[$menu], [$menu]]; |
| 262 | - }else{ |
|
| 262 | + } else{ |
|
| 263 | 263 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | abort(500, 'You should not use 0 as a key in paginator. If you are looking for "ALL" option, use -1 instead.'); |
| 291 | 291 | |
| 292 | - }else{ |
|
| 292 | + } else{ |
|
| 293 | 293 | // developer defined length as setPageLengthMenu([50, 100, 300]) |
| 294 | 294 | // we will use the same values as labels |
| 295 | 295 | if(!in_array(0, $menu)) { |