Passed
Push — master ( 16f676...c127b0 )
by Radu
01:55
created

FromArrayTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 9 3
1
<?php
2
namespace WebServCo\Framework\Traits;
3
4
trait FromArrayTrait
5
{
6
    /**
7
    * Returns an instance of the current class
8
    */
9
    public static function fromArray($data)
10
    {
11
        $object = new static();
12
        foreach (get_object_vars($object) as $property => $default) {
13
            if (array_key_exists($property, $data)) {
14
                $object->{$property} = $data[$property];
15
            }
16
        }
17
        return $object;
18
    }
19
}
20