Passed
Pull Request — main (#3261)
by Sebastian
48:30 queued 07:03
created

ResultPageViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderStatic() 0 5 1
A initializeArguments() 0 4 1
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 ApacheSolrForTypo3\Solr\ViewHelpers\Uri\Paginate;
19
20
use ApacheSolrForTypo3\Solr\ViewHelpers\Uri\AbstractUriViewHelper;
21
use Closure;
22
use TYPO3\CMS\Extbase\Object\Exception as ExtbaseObjectException;
23
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24
25
/**
26
 * Class ResultPageViewHelper
27
 *
28
 * @author Frans Saris <[email protected]>
29
 * @author Timo Hund <[email protected]>
30
 */
31
class ResultPageViewHelper extends AbstractUriViewHelper
32
{
33
    /**
34
     * Initializes the arguments
35
     */
36 26
    public function initializeArguments()
37
    {
38 26
        parent::initializeArguments();
39 26
        $this->registerArgument('page', 'int', 'The page', false, 0);
40
    }
41
42
    /**
43
     * @param array $arguments
44
     * @param Closure $renderChildrenClosure
45
     * @param RenderingContextInterface $renderingContext
46
     * @return string
47
     * @throws ExtbaseObjectException
48
     *
49
     * @noinspection PhpMissingReturnTypeInspection
50
     */
51 2
    public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
52
    {
53 2
        $page = $arguments['page'];
54 2
        $previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
55 2
        return self::getSearchUriBuilder($renderingContext)->getResultPageUri($previousRequest, $page);
0 ignored issues
show
Bug introduced by
It seems like $previousRequest can also be of type null; however, parameter $previousSearchRequest of ApacheSolrForTypo3\Solr\...der::getResultPageUri() does only seem to accept ApacheSolrForTypo3\Solr\...in\Search\SearchRequest, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        return self::getSearchUriBuilder($renderingContext)->getResultPageUri(/** @scrutinizer ignore-type */ $previousRequest, $page);
Loading history...
56
    }
57
}
58