Skip to content

Commit 98820f1

Browse files
[MAINTENANCE] Adjust condition checks and assigments to array (kitodo#1731)
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent f9f0246 commit 98820f1

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

Classes/Command/HarvestCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function configure(): void
9999

100100
/**
101101
* Executes the command to index the given document to DB and SOLR.
102-
*
102+
*
103103
* @access protected
104104
*
105105
* @param InputInterface $input The input parameters
@@ -109,7 +109,7 @@ public function configure(): void
109109
*/
110110
protected function execute(InputInterface $input, OutputInterface $output): int
111111
{
112-
$dryRun = $input->getOption('dry-run') != false ? true : false;
112+
$dryRun = $input->getOption('dry-run') != false;
113113

114114
$io = new SymfonyStyle($input, $output);
115115
$io->title($this->getDescription());

Classes/Command/ReindexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function configure(): void
113113
*/
114114
protected function execute(InputInterface $input, OutputInterface $output): int
115115
{
116-
$dryRun = $input->getOption('dry-run') != false ? true : false;
116+
$dryRun = $input->getOption('dry-run') != false;
117117

118118
$io = new SymfonyStyle($input, $output);
119119
$io->title($this->getDescription());

Classes/Common/Solr/SearchResult/ResultDocument.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function getHighlightsIds(): array
272272
{
273273
$highlightsIds = [];
274274
foreach ($this->highlights as $highlight) {
275-
array_push($highlightsIds, $highlight->getId());
275+
$highlightsIds[] = $highlight->getId();
276276
}
277277
return $highlightsIds;
278278
}
@@ -307,7 +307,7 @@ private function parsePages(): void
307307
$i = 0;
308308
foreach ($pageArray as $pages) {
309309
foreach ($pages as $page) {
310-
array_push($this->pages, new Page($i, $page));
310+
$this->pages[] = new Page($i, $page);
311311
$i++;
312312
}
313313
}
@@ -328,7 +328,7 @@ private function parseRegions(): void
328328
$i = 0;
329329
foreach ($regionArray as $regions) {
330330
foreach ($regions as $region) {
331-
array_push($this->regions, new Region($i, $region));
331+
$this->regions[] = new Region($i, $region);
332332
$i++;
333333
}
334334
}
@@ -349,7 +349,7 @@ private function parseHighlights(): void
349349
foreach ($highlightArray as $highlights) {
350350
foreach ($highlights as $highlight) {
351351
foreach ($highlight as $hl) {
352-
array_push($this->highlights, new Highlight($hl));
352+
$this->highlights[] = new Highlight($hl);
353353
}
354354
}
355355
}
@@ -369,7 +369,7 @@ private function getArrayByIndex(string $index): array
369369
$objectArray = [];
370370
foreach ($this->snippetsForRecord as $snippet) {
371371
if (!empty($snippet[$index])) {
372-
array_push($objectArray, $snippet[$index]);
372+
$objectArray[] = $snippet[$index];
373373
}
374374
}
375375
return $objectArray;

Classes/Controller/AbstractController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,13 @@ protected function buildSimplePagination(PaginationInterface $pagination, Pagina
586586
// page range
587587
for ($i = $nBottom; $i <= $nTop; $i++) {
588588
if ($i > 0 and $i <= $lastPage) {
589-
array_push($aRange, $i);
589+
$aRange[] = $i;
590590
};
591591
};
592592

593593
// check whether the first screen page is > 1, if yes then points must be added
594594
if ($aRange[0] > 1) {
595-
array_push($pagesSect, ['label' => '...','startRecordNumber' => '...']);
595+
$pagesSect[] = ['label' => '...', 'startRecordNumber' => '...'];
596596
};
597597
$lastStartRecordNumberGrid = 0; // due to validity outside the loop
598598
foreach (range($firstPage, $lastPage) as $i) {
@@ -608,7 +608,7 @@ protected function buildSimplePagination(PaginationInterface $pagination, Pagina
608608
// Check if screen page is in range
609609
// <f:for each="{pagination.pagesR}" as="page">
610610
if (in_array($i, $aRange)) {
611-
array_push($pagesSect, ['label' => $i, 'startRecordNumber' => $i]);
611+
$pagesSect[] = ['label' => $i, 'startRecordNumber' => $i];
612612
};
613613
} else { // GridView
614614
// to calculate the values for generation the links for the pagination pages
@@ -635,15 +635,15 @@ protected function buildSimplePagination(PaginationInterface $pagination, Pagina
635635

636636
// Check if screen page is in range
637637
if (in_array($i, $aRange)) {
638-
array_push($pagesSect, ['label' => $i,'startRecordNumber' => $startRecordNumber]);
638+
$pagesSect[] = ['label' => $i, 'startRecordNumber' => $startRecordNumber];
639639
};
640640
};
641641
};
642642

643643
// check whether the last element from $aRange <= last screen page, if yes then points must be added
644644
if ($aRange[array_key_last($aRange)] < $lastPage) {
645-
array_push($pagesSect, ['label' => '...', 'startRecordNumber' => '...']);
646-
};
645+
$pagesSect[] = ['label' => '...', 'startRecordNumber' => '...'];
646+
}
647647

648648
// Safely get the next and previous page numbers
649649
$nextPageNumber = isset($pages[$currentPageNumber + 1]) ? $pages[$currentPageNumber + 1]['startRecordNumber'] : null;

Classes/Controller/SearchController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private function makeFacetsMenuArray(array $facets): array
342342
'key' => $field,
343343
'field' => $field,
344344
'limit' => $this->settings['limitFacets'] ?? 15,
345-
'sort' => isset($this->settings['sortingFacets']) ? $this->settings['sortingFacets'] : 'count'
345+
'sort' => $this->settings['sortingFacets'] ?? 'count'
346346
];
347347
}
348348

0 commit comments

Comments
 (0)