Passed
Push — master ( 3cd8c6...9e747f )
by Timo
38:54 queued 16:17
created

NumericRangeFacetParser::parseResponseValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.5

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2.5
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange;
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\Facets\RangeBased\AbstractRangeFacetParser;
18
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
19
20
/**
21
 * Class NumericRangeFacetParser
22
 *
23
 * @author Frans Saris <[email protected]>
24
 * @author Timo Hund <[email protected]>
25
 * @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets
26
 */
27
class NumericRangeFacetParser extends AbstractRangeFacetParser
28
{
29
    /**
30
     * @var string
31
     */
32
    protected $facetClass = NumericRangeFacet::class;
33
34
    /**
35
     * @var
36
     */
37
    protected $facetItemClass = NumericRange::class;
38
39
    /**
40
     * @var string
41
     */
42
    protected $facetRangeCountClass = NumericRangeCount::class;
43
44
    /**
45
     * @param SearchResultSet $resultSet
46
     * @param string $facetName
47
     * @param array $facetConfiguration
48
     * @return NumericRangeFacet|null
49
     */
50 4
    public function parse(SearchResultSet $resultSet, $facetName, array $facetConfiguration)
51
    {
52 4
        return $this->getParsedFacet(
53
            $resultSet,
54
            $facetName,
55
            $facetConfiguration,
56 4
            $this->facetClass,
57 4
            $this->facetItemClass,
58 4
            $this->facetRangeCountClass
59
        );
60
    }
61
    /**
62
     * @param mixed $rawValue
63
     * @return mixed (numeric value)
64
     */
65 4
    protected function parseRequestValue($rawValue)
66
    {
67 4
        return is_numeric($rawValue) ? $rawValue : 0;
68
    }
69
70
    /**
71
     * @param $rawValue
72
     * @return mixed (numeric value)
73
     */
74 4
    protected function parseResponseValue($rawValue)
75
    {
76 4
        return is_numeric($rawValue) ? $rawValue : 0;
77
    }
78
}
79