Passed
Pull Request — task/3376-TYPO3_12_compatibili... (#3512)
by Rafael
44:01
created

AbstractRangeFacetItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 7
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;
19
20
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacet;
21
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacetItem;
22
23
/**
24
 * Abstract class that is used as base class for range facet items
25
 *
26
 * @author Frans Saris <[email protected]>
27
 * @author Timo Hund <[email protected]>
28
 */
29
abstract class AbstractRangeFacetItem extends AbstractFacetItem
30
{
31
    public function __construct(
32
        protected AbstractFacet $facet,
33
        protected string $label = '',
34
        protected int $documentCount = 0,
35
        protected bool $selected = false,
36
        protected array $metrics = [],
37
        protected array $rangeCounts = [],
38
        protected string|int $gap = '',
39
    ) {
40
        parent::__construct(
41
            $this->facet,
42
            $this->label,
43
            $this->documentCount,
44
            $this->selected,
45
            $this->metrics
46
        );
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getUriValue(): string
53
    {
54
        return $this->getRangeString();
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getCollectionKey(): string
61
    {
62
        return $this->getRangeString();
63
    }
64
65
    /**
66
     * @return array
67
     */
68
    public function getRangeCounts(): array
69
    {
70
        return $this->rangeCounts;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getGap(): string
77
    {
78
        return (string)$this->gap;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    abstract protected function getRangeString(): string;
85
}
86