Passed
Push — master ( 536f48...741d19 )
by Carlos
01:52 queued 12s
created

WorkflowSearch   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 5 1
A search() 0 15 2
1
<?php
2
3
namespace roaresearch\yii2\workflow\roa\models;
4
5
use roaresearch\yii2\roa\ResourceSearch;
6
use yii\data\ActiveDataProvider;
7
8
/**
9
 * Contract to filter and sort collections of `Workflow` records.
10
 *
11
 * @author Angel (Faryshta) Guevara <[email protected]>
12
 */
13
class WorkflowSearch extends Workflow implements ResourceSearch
14
{
15
    /**
16
     * @inhertidoc
17
     */
18 1
    public function rules()
19
    {
20
        return [
21 1
            [['created_by'], 'integer'],
22
            [['name'], 'string'],
23
        ];
24
    }
25
26
    /**
27
     * @inhertidoc
28
     */
29 1
    public function search(
30
        array $params,
31
        ?string $formName = ''
32
    ): ?ActiveDataProvider {
33 1
        $this->load($params, $formName);
34 1
        if (!$this->validate()) {
35 1
            return null;
36
        }
37
38 1
        $class = get_parent_class();
39 1
        return new ActiveDataProvider([
40 1
            'query' => $class::find()->andFilterWhere([
41 1
                    'created_by' => $this->created_by,
0 ignored issues
show
Bug Best Practice introduced by
The property created_by does not exist on roaresearch\yii2\workflo...a\models\WorkflowSearch. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
                ])
43 1
                ->andFilterWhere(['like', 'name', $this->name]),
44
        ]);
45
    }
46
}
47