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

SearchCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 35
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 8 1
A getAttributes() 0 6 1
A fixAttributes() 0 10 3
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