Test Failed
Pull Request — master (#1)
by Angel
04:13
created

SolicitudeValueSimpleSearch::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\formgenerator\roa\models;
4
5
use yii\{base\Model, data\ActiveDataProvider};
6
7
/**
8
 * Contract to filter and sort collections of `SolicitudeValue` records.
9
 *
10
 * Unlike `SolicitudeValueSearch` this class doesnt invoke the parent
11
 * `Solicitude` record so it can search `SolicitudeValue` records across
12
 * different `Solicitude` records.
13
 *
14
 * @author Angel (Faryshta) Guevara <[email protected]>
15
 */
16
class SolicitudeValueSimpleSearch extends SolicitudeValue implements
17
    \roaresearch\yii2\roa\ResourceSearch
18
{
19
    /**
20
     * @inhertidoc
21
     */
22
    protected function slugBehaviorConfig(): array
23 1
    {
24
        return [
25
            'idAttribute' => [],
26 1
            'parentSlugRelation' => null,
27
            'resourceName' => 'solicitude-value',
28
        ];
29
    }
30
31
    /**
32
     * @inhertidoc
33
     */
34
    public function attributes()
35 1
    {
36
        return array_merge(parent::attributes(), ['form_id']);
37 1
    }
38
39
    /**
40
     * @inhertidoc
41
     */
42
    public function rules()
43 1
    {
44
        return [
45
            [['form_id', 'solicitude_id', 'section_id', 'field_id'], 'integer'],
46 1
            [['value'], 'safe'],
47
        ];
48
    }
49
50
    /**
51
     * @inhertidoc
52
     */
53
    public function search(
54 1
        array $params,
55
        ?string $formName = ''
56
    ): ?ActiveDataProvider {
57
        $this->load($params, $formName);
58 1
        if (!$this->validate()) {
59 1
            return null;
60 1
        }
61
        $this->checkAccess($params);
0 ignored issues
show
Bug introduced by
The method checkAccess() does not exist on roaresearch\yii2\formgen...citudeValueSimpleSearch. 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

61
        $this->/** @scrutinizer ignore-call */ 
62
               checkAccess($params);
Loading history...
62 1
        $class = get_parent_class();
63 1
64
        return new ActiveDataProvider([
65 1
            'query' => $class::find()->innerJoinWith(['solicitude'])
66 1
                ->andFilterWhere([
67 1
                    'form_id' => $this->form_id,
0 ignored issues
show
Bug Best Practice introduced by
The property form_id does not exist on roaresearch\yii2\formgen...citudeValueSimpleSearch. Since you implemented __get, consider adding a @property annotation.
Loading history...
68 1
                    'solicitude_id' => $this->solicitude_id,
69 1
                    'section_id' => $this->section_id,
70 1
                    'field_id' => $this->field_id,
71 1
                ])->andFilterWhere(['like', 'value', $this->value])
72 1
        ]);
73
    }
74
75
    /**
76
     * @inhertidoc
77
     */
78
    public function afterValidate()
79 1
    {
80
        Model::afterValidate();
81 1
    }
82
}
83