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

StartNewSearchViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 4 1
A renderStatic() 0 6 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