Completed
Push — master ( 2f5812...089fcb )
by Denis
03:11
created

BaseConfig::getDefaultLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Artprima\QueryFilterBundle\QueryFilter\Config;
4
5
use Artprima\QueryFilterBundle\Request\Request;
6
7
/**
8
 * Class BaseConfig
9
 *
10
 * @author Denis Voytyuk <[email protected]>
11
 *
12
 * @package Artprima\QueryFilterBundle\QueryFilter\Config
13
 */
14
class BaseConfig implements ConfigInterface
15
{
16
    /**
17
     * @var Request
18
     */
19
    protected $request;
20
21
    /**
22
     * @var int
23
     */
24
    protected $defaultLimit;
25
26
    /**
27
     * @var array
28
     */
29
    protected $allowedLimits;
30
31
    /**
32
     * @var array
33
     */
34
    protected $searchBy = [
35
        'args' => [],
36
        'aliases' => [],
37
        'extra' => [],
38
    ];
39
40
    /**
41
     * @var array
42
     */
43
    protected $sort = [
44
        'cols' => [],
45
        'default' => [],
46
    ];
47
48
    /**
49
     * @var callable
50
     */
51
    protected $repositoryCallback;
52
53
    /**
54
     * @var callable
55
     */
56
    protected $totalRowsCallback;
57
58
    /**
59
     * @var bool
60
     */
61
    protected $simple = true;
62
63
    /**
64
     * @inheritdoc
65
     */
66 2
    public function setSearchAllowedCols(array $args): ConfigInterface
67
    {
68 2
        $this->searchBy['args'] = $args;
69
70 2
        return $this;
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76 2
    public function getSearchAllowedCols(): array
77
    {
78 2
        return $this->searchBy['args'];
79
    }
80
81
    /**
82
     * @inheritdoc
83
     */
84
    public function setSearchByAliases(array $aliases): ConfigInterface
85
    {
86
        $this->searchBy['aliases'] = $aliases;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @inheritdoc
93
     */
94 2
    public function getSearchByAliases(): array
95
    {
96 2
        return $this->searchBy['aliases'];
97
    }
98
99
    /**
100
     * @inheritdoc
101
     */
102
    public function setSearchByExtra(callable $extra): ConfigInterface
103
    {
104
        $this->searchBy['extra'] = $extra;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @inheritdoc
111
     */
112 2
    public function getSearchByExtra(): array
113
    {
114 2
        return $this->searchBy['extra'];
115
    }
116
117
    /**
118
     * @inheritdoc
119
     */
120 2
    public function setSortCols(array $cols, array $default = []): ConfigInterface
121
    {
122 2
        $this->sort['cols'] = $cols;
123 2
        $this->sort['default'] = $default;
124
125 2
        return $this;
126
    }
127
128
    /**
129
     * @inheritdoc
130
     */
131 2
    public function getSortCols(): array
132
    {
133 2
        return $this->sort['cols'];
134
    }
135
136
    /**
137
     * @inheritdoc
138
     */
139 2
    public function getSortColsDefault(): array
140
    {
141 2
        return $this->sort['default'];
142
    }
143
144
    /**
145
     * @inheritdoc
146
     */
147 3
    public function setRepositoryCallback(callable $callback): ConfigInterface
148
    {
149 3
        $this->repositoryCallback = $callback;
150
151 3
        return $this;
152
    }
153
154
    /**
155
     * @inheritdoc
156
     */
157 2
    public function getRepositoryCallback(): callable
158
    {
159 2
        return $this->repositoryCallback;
160
    }
161
162
    /**
163
     * @inheritdoc
164
     */
165 2
    public function getAllowedLimits(): array
166
    {
167 2
        return $this->allowedLimits;
168
    }
169
170
    /**
171
     * @inheritdoc
172
     */
173 2
    public function setAllowedLimits(array $allowedLimits): ConfigInterface
174
    {
175 2
        $this->allowedLimits = $allowedLimits;
176
177 2
        return $this;
178
    }
179
180
    /**
181
     * @inheritdoc
182
     */
183 2
    public function setDefaultLimit(int $limit): ConfigInterface
184
    {
185 2
        $this->defaultLimit = $limit;
186
187 2
        return $this;
188
    }
189
190
    /**
191
     * @inheritdoc
192
     */
193
    public function getDefaultLimit(): int
194
    {
195
        return $this->defaultLimit;
196
    }
197
198
199
    /**
200
     * @inheritdoc
201
     */
202
    public function getTotalRowsCallback(): callable
203
    {
204
        return $this->totalRowsCallback;
205
    }
206
207
    /**
208
     * @inheritdoc
209
     */
210 1
    public function setTotalRowsCallback(callable $totalRowsCallback): ConfigInterface
211
    {
212 1
        $this->totalRowsCallback = $totalRowsCallback;
213
214 1
        return $this;
215
    }
216
217
    /**
218
     * @return Request
219
     */
220 2
    public function getRequest(): Request
221
    {
222 2
        return $this->request;
223
    }
224
225
    /**
226
     * @inheritdoc
227
     */
228 3
    public function setRequest(Request $request): ConfigInterface
229
    {
230 3
        $this->request = $request;
231
232 3
        return $this;
233
    }
234
}
235