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

Update   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A proct() 0 9 2
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