Completed
Push — master ( 142578...5f4f14 )
by Igor
06:03
created

Model   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A collectErrors() 0 12 3
1
<?php
2
3
namespace app\helpers;
4
5
use yii\helpers\Html;
6
7
class Model
8
{
9
   /**
10
    * Collect model errors
11
    *
12
    * @param Model $model the model to be validated
13
    * @return array the error message array indexed by the attribute IDs.
14
    */
15 11
    public static function collectErrors($model)
16
    {
17 11
        $result = [];
18
        /* @var $model Model */
19 11
        $models = [$model];
20 11
        foreach ($models as $model) {
21 11
            foreach ($model->getErrors() as $attribute => $errors) {
0 ignored issues
show
Bug introduced by
The method getErrors() does not seem to exist on object<app\helpers\Model>.

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...
22 11
                $result[Html::getInputId($model, $attribute)] = $errors;
0 ignored issues
show
Documentation introduced by
$model is of type object<app\helpers\Model>, but the function expects a object<yii\base\Model>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
            }
24
        }
25 11
        return $result;
26
    }
27
}
28