Passed
Push — task/3376-TYPO3_12_compatibili... ( 4a64aa...1a121c )
by Rafael
44:51
created

NumericRangeFacet::setRange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\NumericRange;
19
20
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacet;
21
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacetItemCollection;
22
23
/**
24
 * Value object that represent a date range facet.
25
 *
26
 * @author Frans Saris <[email protected]>
27
 * @author Timo Hund <[email protected]>
28
 */
29
class NumericRangeFacet extends AbstractFacet
30
{
31
    public const TYPE_NUMERIC_RANGE = 'numericRange';
32
33
    /**
34
     * String
35
     * @var string
36
     */
37
    protected static string $type = self::TYPE_NUMERIC_RANGE;
38
39
    /**
40
     * @var NumericRange|null
41
     */
42
    protected ?NumericRange $numericRange = null;
43
44
    /**
45
     * @param NumericRange $range
46
     */
47
    public function setRange(NumericRange $range)
48
    {
49
        $this->numericRange = $range;
50
    }
51
52
    /**
53
     * @return NumericRange
54
     */
55
    public function getRange(): NumericRange
56
    {
57
        return $this->numericRange;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->numericRange could return the type null which is incompatible with the type-hinted return ApacheSolrForTypo3\Solr\...mericRange\NumericRange. Consider adding an additional type-check to rule them out.
Loading history...
58
    }
59
60
    /**
61
     * Get facet partial name used for rendering the facet
62
     *
63
     * @return string
64
     */
65
    public function getPartialName(): string
66
    {
67
        return !empty($this->configuration['partialName']) ? $this->configuration['partialName'] : 'RangeNumeric.html';
68
    }
69
70
    /**
71
     * Since the DateRange contains only one or two items when return a collection with the range only to
72
     * allow to render the date range as other facet items.
73
     *
74
     * @return AbstractFacetItemCollection
75
     */
76
    public function getAllFacetItems(): AbstractFacetItemCollection
77
    {
78
        return new NumericRangeCollection([$this->numericRange]);
79
    }
80
}
81