Completed
Push — master ( 077f63...ceb768 )
by Andrii
02:53
created

SearchCommand::getAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hiapi\commands;
4
5
class SearchCommand extends BaseCommand
6
{
7
    protected static $handler = SearchHandler::class;
8
9
    public $select;
10
    public $where;
11
    public $limit;
12
13
    public function rules()
14
    {
15
        return [
16
            ['select', 'safe'],
17
            ['where', 'safe'],
18
            ['limit', 'number', 'max' => 100],
19
        ];
20
    }
21
22
    public function getAttributes()
23
    {
24
        $this->fixAttributes();
25
26
        return parent::getAttributes();
27
    }
28
29
    public function fixAttributes()
30
    {
31
        if (is_string($this->select)) {
32
            $this->select = explode(',', $this->select);
33
        }
34
35
        if (!$this->limit) {
36
            $this->limit = 25;
37
        }
38
    }
39
}
40