Test Failed
Pull Request — master (#1)
by Angel
07:17
created

WorkflowSearch::search()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 2
rs 10
c 0
b 0
f 0
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