Passed
Push — main ( 6bf038...578b82 )
by Aleksandr
03:45 queued 32s
created

Fillable::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DalliSDK\Traits;
6
7
trait Fillable
8
{
9 146
    public function __construct(array $data = [])
10
    {
11 146
        foreach ($data as $key => $value) {
12 144
            if (!\property_exists($this, $key)) {
13 1
                throw new \InvalidArgumentException(\sprintf('The class "%s" does not have the property "%s"', static::class, $key));
14
            }
15 144
            $this->{$key} = $value;
16
        }
17
    }
18
19
20 141
    public static function create($data = [])
21
    {
22 141
        \assert(\is_array($data));
23 141
        return new static($data);
24
    }
25
}
26