Failed Conditions
Pull Request — task/2976_TYPO3.11_compatibili... (#3097)
by
unknown
44:13
created

ResultsPaginator::getTotalAmountOfItems()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Pagination;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
18
use TYPO3\CMS\Core\Pagination\AbstractPaginator;
19
20
/**
21
 * Class ResultsPaginator
22
 *
23
 * @author Rudy Gnodde <[email protected]>
24
 */
25
class ResultsPaginator extends AbstractPaginator
26
{
27
    /**
28
     * @var SearchResultSet
29
     */
30
    protected $resultSet;
31
32
    /**
33
     * @param SearchResultSet $resultSet
34
     * @param int $currentPageNumber
35
     * @param int $itemsPerPage
36
     */
37
    public function __construct(
38
        SearchResultSet $resultSet,
39
        int $currentPageNumber = 1,
40
        int $itemsPerPage = 10
41
    ) {
42
        $this->resultSet = $resultSet;
43
        $this->setCurrentPageNumber($currentPageNumber);
44
        $this->setItemsPerPage($itemsPerPage);
45
46
        $this->updateInternalState();
47
    }
48
49
    /**
50
     * @return iterable
51
     */
52
    public function getPaginatedItems(): iterable
53
    {
54
        return $this->resultSet->getSearchResults();
55
    }
56
57
    /**
58
     * @param int $itemsPerPage
59
     * @param int $offset
60
     */
61
    public function updatePaginatedItems(int $itemsPerPage, int $offset): void
62
    {
63
    }
64
65
    /**
66
     * @return int
67
     */
68
    public function getAmountOfItemsOnCurrentPage(): int
69
    {
70
        return $this->resultSet->getSearchResults()->count();
71
    }
72
73
    /**
74
     * @return int
75
     */
76
    public function getTotalAmountOfItems(): int
77
    {
78
        return $this->resultSet->getAllResultCount();
79
    }
80
81
}
82