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

FakedValidationModel::createWithAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 1
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