Test Failed
Pull Request — master (#1)
by Angel
03:51
created

SolicitudeValueSearch::search()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2.0017

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 2
dl 0
loc 18
ccs 12
cts 13
cp 0.9231
crap 2.0017
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\formgenerator\roa\models;
4
5
use roaresearch\yii2\roa\ResourceSearch;
6
use yii\base\Model;
7
use yii\data\ActiveDataProvider;
8
9
/**
10
 * Contract to filter and sort collections of `SolicitudeValue` records.
11
 *
12
 * @author Angel (Faryshta) Guevara <[email protected]>
13
 */
14
class SolicitudeValueSearch extends SolicitudeValue implements ResourceSearch
15
{
16
    /**
17
     * @inhertidoc
18
     */
19 2
    protected function slugBehaviorConfig(): array
20
    {
21
        return [
22 2
            'idAttribute' => [],
23
            'parentSlugRelation' => 'solicitude',
24
            'resourceName' => 'value',
25
        ];
26
    }
27
28
    /**
29
     * @inhertidoc
30
     */
31 2
    public function rules()
32
    {
33
        return [
34 2
            [['solicitude_id'], 'required'],
35
            [['solicitude_id', 'section_id', 'field_id'], 'integer'],
36
            [['value'], 'safe'],
37
        ];
38
    }
39
40
    /**
41
     * @inhertidoc
42
     */
43 2
    public function search(
44
        array $params,
45
        ?string $formName = ''
46
    ): ?ActiveDataProvider {
47 2
        $this->load($params, $formName);
48 2
        if (!$this->validate()) {
49
            return null;
50
        }
51 2
        $this->checkAccess($params);
0 ignored issues
show
Bug introduced by
The method checkAccess() does not exist on roaresearch\yii2\formgen...s\SolicitudeValueSearch. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $this->/** @scrutinizer ignore-call */ 
52
               checkAccess($params);
Loading history...
52 2
        $class = get_parent_class();
53
54 2
        return new ActiveDataProvider([
55 2
            'query' => $class::find()->innerJoinWith(['solicitude'])
56 2
                ->andFilterWhere([
57 2
                    'solicitude_id' => $this->solicitude_id,
58 2
                    'section_id' => $this->section_id,
59 2
                    'field_id' => $this->field_id,
60 2
                ])->andFilterWhere(['like', 'value', $this->value])
61
        ]);
62
    }
63
64
    /**
65
     * @inhertidoc
66
     */
67 2
    public function afterValidate()
68
    {
69 2
        Model::afterValidate();
70 2
    }
71
}
72