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

StartNewSearchViewHelper::renderStatic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Uri\Search;
17
18
use ApacheSolrForTypo3\Solr\ViewHelpers\Uri\AbstractUriViewHelper;
19
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
20
21
/**
22
 * Class StartNewSearchViewHelper
23
 *
24
 * @author Frans Saris <[email protected]>
25
 * @author Timo Hund <[email protected]>
26
 */
27
class StartNewSearchViewHelper extends AbstractUriViewHelper
28
{
29
30
    /**
31
     * Initializes the arguments
32
     */
33 2
    public function initializeArguments()
34
    {
35 2
        parent::initializeArguments();
36 2
        $this->registerArgument('queryString', 'string', 'The query string', false, '');
37
    }
38
39
    /**
40
     * @param array $arguments
41
     * @param \Closure $renderChildrenClosure
42
     * @param RenderingContextInterface $renderingContext
43
     * @return string
44
     */
45 1
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
46
    {
47 1
        $queryString = $arguments['queryString'];
48 1
        $previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
49 1
        $uri = self::getSearchUriBuilder($renderingContext)->getNewSearchUri($previousRequest, $queryString);
0 ignored issues
show
Bug introduced by
It seems like $previousRequest can also be of type null; however, parameter $previousSearchRequest of ApacheSolrForTypo3\Solr\...lder::getNewSearchUri() 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

49
        $uri = self::getSearchUriBuilder($renderingContext)->getNewSearchUri(/** @scrutinizer ignore-type */ $previousRequest, $queryString);
Loading history...
50 1
        return $uri;
51
    }
52
}
53