Passed
Pull Request — master (#25)
by Alexander
14:50
created

ValidatorTestRefModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 2
A getMain() 0 3 1
A tableName() 0 3 1
1
<?php
2
namespace Yiisoft\Validator\Tests\data;
3
4
use Yiisoft\Validator\DataSetInterface;
5
6
class ValidatorTestRefModel implements DataSetInterface
7
{
8
    public $test_val = 2;
9
    public $test_val_fail = 99;
10
11
    public function getValue(string $key)
12
    {
13
        if (property_exists(self::class, $key)) {
14
            return $this->$key;
15
        }
16
    }
17
18
    public static function tableName()
19
    {
20
        return 'validator_ref';
21
    }
22
23
    public function getMain()
24
    {
25
        return $this->hasOne(ValidatorTestMainModel::class, ['id' => 'ref']);
0 ignored issues
show
Bug introduced by
The method hasOne() does not exist on Yiisoft\Validator\Tests\data\ValidatorTestRefModel. ( Ignorable by Annotation )

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

25
        return $this->/** @scrutinizer ignore-call */ hasOne(ValidatorTestMainModel::class, ['id' => 'ref']);

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...
26
    }
27
}
28