Passed
Pull Request — release-11.5.x (#3206)
by Michael
41:07
created

NumericRangeFacet::getRange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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\AbstractFacet;
18
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacetItemCollection;
19
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
20
21
/**
22
 * Value object that represent a date range facet.
23
 *
24
 * @author Frans Saris <[email protected]>
25
 * @author Timo Hund <[email protected]>
26
 */
27
class NumericRangeFacet extends AbstractFacet
28
{
29
    const TYPE_NUMERIC_RANGE = 'numericRange';
30
31
    /**
32
     * String
33
     * @var string
34
     */
35
    protected static $type = self::TYPE_NUMERIC_RANGE;
36
37
    /**
38
     * @var NumericRange
39
     */
40
    protected $numericRange;
41
42
    /**
43
     * OptionsFacet constructor
44
     *
45
     * @param SearchResultSet $resultSet
46
     * @param string $name
47
     * @param string $field
48
     * @param string $label
49
     * @param array $configuration Facet configuration passed from typoscript
50
     */
51 4
    public function __construct(SearchResultSet $resultSet, $name, $field, $label = '', array $configuration = [])
52
    {
53 4
        parent::__construct($resultSet, $name, $field, $label, $configuration);
54
    }
55
56
    /**
57
     * @param NumericRange $range
58
     */
59 4
    public function setRange(NumericRange $range)
60
    {
61 4
        $this->numericRange = $range;
62
    }
63
64
    /**
65
     * @return NumericRange
66
     */
67 4
    public function getRange()
68
    {
69 4
        return $this->numericRange;
70
    }
71
72
73
    /**
74
     * Get facet partial name used for rendering the facet
75
     *
76
     * @return string
77
     */
78
    public function getPartialName()
79
    {
80
        return !empty($this->configuration['partialName']) ? $this->configuration['partialName'] : 'RangeNumeric.html';
81
    }
82
83
    /**
84
     * Since the DateRange contains only one or two items when return a collection with the range only to
85
     * allow to render the date range as other facet items.
86
     *
87
     * @return AbstractFacetItemCollection
88
     */
89
    public function getAllFacetItems()
90
    {
91
        return new NumericRangeCollection([$this->numericRange]);
92
    }
93
}
94