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

SolicitudeValueSearch   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 56
ccs 18
cts 19
cp 0.9474
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A afterValidate() 0 3 1
A rules() 0 6 1
A slugBehaviorConfig() 0 6 1
A search() 0 18 2
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