Passed
Pull Request — master (#123)
by
unknown
04:15
created

SolrSearchQuery::lessThan()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 1
rs 10
1
<?php
2
3
namespace Kitodo\Dlf\Common\Solr;
4
5
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
6
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface;
7
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface;
8
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
9
10
/**
11
 * Targeted towards being used in ``PaginateController`` (``<f:widget.paginate>``).
12
 *
13
 * @package TYPO3
14
 * @subpackage dlf
15
 *
16
 * @access public
17
 *
18
 * @property int $limit
19
 * @property int $offset
20
 */
21
class SolrSearchQuery implements QueryInterface
22
{
23
    /**
24
     * @access private
25
     * @var SolrSearch
26
     */
27
    private SolrSearch $solrSearch;
28
29
    /**
30
     * @access private
31
     * @var int
32
     */
33
    private int $limit;
34
35
    /**
36
     * @access private
37
     * @var int
38
     */
39
    private int $offset;
40
41
     /**
42
     * Constructs SolrSearchQuery instance.
43
     *
44
     * @access public
45
     *
46
     * @param SolrSearch $solrSearch
47
     *
48
     * @return void
49
     */
50
    public function __construct($solrSearch)
51
    {
52
        $this->solrSearch = $solrSearch;
53
54
        $this->offset = 0;
55
        $this->limit = count($solrSearch);
56
    }
57
58
    // this class contains a lot of methods which are inherited but not implemented
59
    // @phpstan-ignore-next-line
60
    public function getSource() {}
61
62
    /**
63
     * Executes SOLR search query.
64
     *
65
     * @access public
66
     *
67
     * @param bool $returnRawQueryResult
68
     *
69
     * @return array
70
     */
71
    // TODO: Return type (array) of method SolrSearchQuery::execute() should be compatible with return type (iterable<object>&TYPO3\CMS\Extbase\Persistence\QueryResultInterface) of method TYPO3\CMS\Extbase\Persistence\QueryInterface::execute()
72
    // @phpstan-ignore-next-line
73
    public function execute($returnRawQueryResult = false)
74
    {
75
        $this->solrSearch->submit($this->offset, $this->limit);
76
77
        // solrSearch now only contains the results in range, indexed in [0, n)
78
        $result = [];
79
        $limit = min($this->limit, $this->solrSearch->getNumLoadedDocuments());
80
        for ($i = 0; $i < $limit; $i++) {
81
            $result[] = $this->solrSearch[$i];
82
        }
83
        return $result;
84
    }
85
86
    // @phpstan-ignore-next-line
87
    public function setOrderings(array $orderings) {}
88
89
    /**
90
     * Sets limit for SOLR search query.
91
     *
92
     * @access public
93
     *
94
     * @param int $limit
95
     *
96
     * @return SolrSearchQuery
97
     */
98
    public function setLimit($limit): SolrSearchQuery
99
    {
100
        $this->limit = $limit;
101
        return $this;
102
    }
103
104
    /**
105
     * Sets offset for SOLR search query.
106
     *
107
     * @access public
108
     *
109
     * @param int $offset
110
     *
111
     * @return SolrSearchQuery
112
     */
113
    public function setOffset($offset): SolrSearchQuery
114
    {
115
        $this->offset = $offset;
116
        return $this;
117
    }
118
119
    // @phpstan-ignore-next-line
120
    public function matching($constraint) {}
121
    // @phpstan-ignore-next-line
122
    public function logicalAnd($constraint1) {}
123
    // @phpstan-ignore-next-line
124
    public function logicalOr($constraint1) {}
125
    // @phpstan-ignore-next-line
126
    public function logicalNot(ConstraintInterface $constraint) {}
127
    // @phpstan-ignore-next-line
128
    public function equals($propertyName, $operand, $caseSensitive = true) {}
129
    // @phpstan-ignore-next-line
130
    public function like($propertyName, $operand) {}
131
    // @phpstan-ignore-next-line
132
    public function contains($propertyName, $operand) {}
133
    // @phpstan-ignore-next-line
134
    public function in($propertyName, $operand) {}
135
    // @phpstan-ignore-next-line
136
    public function lessThan($propertyName, $operand) {}
137
    // @phpstan-ignore-next-line
138
    public function lessThanOrEqual($propertyName, $operand) {}
139
    // @phpstan-ignore-next-line
140
    public function greaterThan($propertyName, $operand) {}
141
    // @phpstan-ignore-next-line
142
    public function greaterThanOrEqual($propertyName, $operand) {}
143
    // @phpstan-ignore-next-line
144
    public function getType() {}
145
    public function setQuerySettings(QuerySettingsInterface $querySettings) {}
146
    // @phpstan-ignore-next-line
147
    public function getQuerySettings() {}
148
149
    public function count()
150
    {// @phpstan-ignore-next-line
151
        // TODO?
152
    }
153
154
    // @phpstan-ignore-next-line
155
    public function getOrderings() {}
156
157
    /**
158
     * Gets limit for SOLR search query.
159
     *
160
     * @access public
161
     *
162
     * @return int
163
     */
164
    public function getLimit(): int
165
    {
166
        return $this->limit;
167
    }
168
169
    /**
170
     * Gets offset for SOLR search query.
171
     *
172
     * @access public
173
     *
174
     * @return int
175
     */
176
    public function getOffset(): int
177
    {
178
        return $this->offset;
179
    }
180
181
    // @phpstan-ignore-next-line
182
    public function getConstraint() {}
183
    public function isEmpty($propertyName) {}
0 ignored issues
show
Unused Code introduced by
The parameter $propertyName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

183
    public function isEmpty(/** @scrutinizer ignore-unused */ $propertyName) {}

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
184
    public function setSource(SourceInterface $source) {}
185
    // @phpstan-ignore-next-line
186
    public function getStatement() {}
187
}
188