Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#885)
by
unknown
08:26
created

PageGridPaginator::getPaginatedItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace Kitodo\Dlf\Pagination;
19
20
use TYPO3\CMS\Core\Pagination\AbstractPaginator;
21
22
final class PageGridPaginator extends AbstractPaginator
23
{
24
    /**
25
     * @var array
26
     */
27
    private $items;
28
29
    /**
30
     * @var int
31
     */
32
    public $publicItemsPerPage;
33
34
    /**
35
     * @var array
36
     */
37
    private $paginatedItems = [];
38
39
    public function __construct(
40
        array $items,
41
        int $currentPageNumber = 1,
42
        int $itemsPerPage = 10
43
    ) {
44
        $this->items = $items;
45
        $this->publicItemsPerPage = $itemsPerPage;
46
        $this->setCurrentPageNumber((int) ceil(($currentPageNumber / $this->publicItemsPerPage)));
47
        $this->setItemsPerPage($itemsPerPage);
48
49
        $this->updateInternalState();
50
    }
51
52
    /**
53
     * @return iterable|array
54
     */
55
    public function getPaginatedItems(): iterable
56
    {
57
        return $this->paginatedItems;
58
    }
59
60
    protected function updatePaginatedItems(int $itemsPerPage, int $offset): void
61
    {
62
        $this->paginatedItems = array_slice($this->items, $offset, $itemsPerPage);
63
    }
64
65
    protected function getTotalAmountOfItems(): int
66
    {
67
        return count($this->items);
68
    }
69
70
    protected function getAmountOfItemsOnCurrentPage(): int
71
    {
72
        return count($this->paginatedItems);
73
    }
74
75
    /**
76
     * @return int
77
     */
78
    public function getPublicItemsPerPage(): int
79
    {
80
        return $this->publicItemsPerPage;
81
    }
82
83
    /**
84
     * @param int $publicItemsPerPage
85
     */
86
    public function setPublicItemsPerPage(int $publicItemsPerPage): void
87
    {
88
        $this->publicItemsPerPage = $publicItemsPerPage;
89
    }
90
91
92
}
93