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

FakedValidationModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 2
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 2
A createWithAttributes() 0 8 2
1
<?php
2
namespace Yiisoft\Validator\Tests\data;
3
4
use Yiisoft\Validator\DataSetInterface;
5
6
class FakedValidationModel implements DataSetInterface
7
{
8
    public $attr_timestamp = false;
9
10
    public $attr_date;
11
12
    public function getValue(string $key)
13
    {
14
        if (property_exists(self::class, $key)) {
15
            return $this->$key;
16
        }
17
    }
18
19
    public static function createWithAttributes($attributes): FakedValidationModel
20
    {
21
        $model = new self();
22
        foreach ($attributes as $attribute => $value) {
23
            $model->$attribute = $value;
24
        }
25
26
        return $model;
27
    }
28
}
29