Completed
Push — master ( 1bd1cf...a95893 )
by Timo
16s
created

NumericRange::getEndRequested()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

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 1
eloc 2
nc 1
nop 0
crap 1.125
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\ViewHelper\Date;
18
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\RangeBased\AbstractRangeFacetItem;
19
20
/**
21
 * Value object that represent an option of a numric range facet.
22
 *
23
 * @author Frans Saris <[email protected]>
24
 * @author Timo Hund <[email protected]>
25
 * @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionsFacet
26
 */
27
class NumericRange extends AbstractRangeFacetItem
28
{
29
    /**
30
     * @var float
31
     */
32
    protected $startRequested;
33
34
    /**
35
     * @var float
36
     */
37
    protected $endRequested;
38
39
    /**
40
     * @var float
41
     */
42
    protected $startInResponse;
43
44
    /**
45
     * @var float
46
     */
47
    protected $endInResponse;
48
49
    /**
50
     * @param NumericRangeFacet $facet
51
     * @param float|null $startRequested
52
     * @param float|null $endRequested
53
     * @param float|null $startInResponse
54
     * @param float|null $endInResponse
55
     * @param string $gap
56
     * @param int $documentCount
57
     * @param array $rangeCounts
58
     * @param bool $selected
59
     */
60 4
    public function __construct(NumericRangeFacet $facet, $startRequested = null, $endRequested = null, $startInResponse = null, $endInResponse = null, $gap = '', $documentCount = 0, $rangeCounts, $selected = false)
61
    {
62 4
        $this->startInResponse = $startInResponse;
63 4
        $this->endInResponse = $endInResponse;
64 4
        $this->startRequested = $startRequested;
65 4
        $this->endRequested = $endRequested;
66 4
        $this->rangeCounts = $rangeCounts;
67 4
        $this->gap = $gap;
68
69 4
        $label = '';
70 4
        if ($startRequested !== null && $endRequested !== null) {
71 4
            $label = $this->getRangeString();
72
        }
73
74
75 4
        parent::__construct($facet, $label, $documentCount, $selected);
76 4
    }
77
78
    /**
79
     * @return string
80
     */
81 4
    protected function getRangeString()
82
    {
83 4
        return $this->startRequested . '-' . $this->endRequested;
84
    }
85
86
    /**
87
     * Retrieves the end date that was requested by the user for this facet.
88
     *
89
     * @return float
90
     */
91 4
    public function getEndRequested()
92
    {
93 4
        return $this->endRequested;
94
    }
95
96
    /**
97
     * Retrieves the start date that was requested by the used for the facet.
98
     *
99
     * @return float
100
     */
101 4
    public function getStartRequested()
102
    {
103 4
        return $this->startRequested;
104
    }
105
106
    /**
107
     * Retrieves the end date that was received from solr for this facet.
108
     *
109
     * @return float
110
     */
111 1
    public function getEndInResponse()
112
    {
113 1
        return $this->endInResponse;
114
    }
115
116
    /**
117
     * Retrieves the start date that was received from solr for this facet.
118
     *
119
     * @return float
120
     */
121 1
    public function getStartInResponse()
122
    {
123 1
        return $this->startInResponse;
124
    }
125
}
126