Test Failed
Pull Request — master (#6)
by Angel
03:38
created

Update::proct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\roa\actions;
4
5
use roaresearch\yii2\roa\hal\ARContract;
6
use Yii;
7
use yii\{base\Model, web\ServerErrorHttpException};
8
9
/**
10
 * Action to update the attributes in a record.
11
 * @author Angel (Faryshta) Guevara <[email protected]>
12
 */
13
class Update extends ProctRecordAction
14
{
15
    use LoadFileTrait;
16
17
    /**
18
     * @inheritdoc
19
     */
20
    protected string $errorMessage = 'Update failed for unknown reasons.';
21
22
    /**
23
     * @var string the scenario to be assigned to the model before it is
24
     * validated and updated.
25
     */
26
    public string $scenario = Model::SCENARIO_DEFAULT;
27
28
    /**
29
     * @inheritdoc
30
     */
31
    protected function proct(ARContract $model, array $params): bool
32 2
    {
33
        $model->scenario = $this->scenario;
0 ignored issues
show
Bug introduced by
Accessing scenario on the interface roaresearch\yii2\roa\hal\ARContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
34
        $model->load(
0 ignored issues
show
Bug introduced by
The method load() does not exist on roaresearch\yii2\roa\hal\ARContract. ( Ignorable by Annotation )

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

34
        $model->/** @scrutinizer ignore-call */ 
35
                load(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35 2
            Yii::$app->request->getBodyParams() + $this->parseFileAttributes(),
36 2
            ''
37 2
        );
38 2
39 2
        return false !== $model->save() || $model->hasErrors();
0 ignored issues
show
Bug introduced by
The method hasErrors() does not exist on roaresearch\yii2\roa\hal\ARContract. ( Ignorable by Annotation )

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

39
        return false !== $model->save() || $model->/** @scrutinizer ignore-call */ hasErrors();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40 2
    }
41
}
42