Passed
Push — master ( 6d83d0...d2efa3 )
by Timo
45:45 queued 16:20
created

NumericRangeFacetParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.037

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 9
cp 0.6667
rs 10
cc 1
nc 1
nop 3
crap 1.037
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
 */
26
class NumericRangeFacetParser extends AbstractRangeFacetParser
27
{
28
    /**
29
     * @var string
30
     */
31
    protected $facetClass = NumericRangeFacet::class;
32
33
    /**
34
     * @var string
35
     */
36
    protected $facetItemClass = NumericRange::class;
37
38
    /**
39
     * @var string
40
     */
41
    protected $facetRangeCountClass = NumericRangeCount::class;
42
43
    /**
44
     * @param SearchResultSet $resultSet
45
     * @param string $facetName
46
     * @param array $facetConfiguration
47
     * @return NumericRangeFacet|null
48
     */
49 4
    public function parse(SearchResultSet $resultSet, $facetName, array $facetConfiguration)
50
    {
51 4
        return $this->getParsedFacet(
52 4
            $resultSet,
53
            $facetName,
54
            $facetConfiguration,
55 4
            $this->facetClass,
56 4
            $this->facetItemClass,
57 4
            $this->facetRangeCountClass
58
        );
59
    }
60
    /**
61
     * @param mixed $rawValue
62
     * @return mixed (numeric value)
63
     */
64 4
    protected function parseRequestValue($rawValue)
65
    {
66 4
        return is_numeric($rawValue) ? $rawValue : 0;
67
    }
68
69
    /**
70
     * @param $rawValue
71
     * @return mixed (numeric value)
72
     */
73 4
    protected function parseResponseValue($rawValue)
74
    {
75 4
        return is_numeric($rawValue) ? $rawValue : 0;
76
    }
77
}
78