Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | 6 | public static function createFromJson(\stdClass $json) |
|
26 | { |
||
27 | 6 | $resource = new static; |
|
28 | 6 | $class = new \ReflectionClass($resource); |
|
29 | |||
30 | 6 | foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { |
|
31 | 6 | if (isset($json->{$property->getName()})) { |
|
32 | 6 | $resource->{$property->getName()} = $json->{$property->getName()}; |
|
33 | 4 | } |
|
34 | 4 | } |
|
35 | |||
36 | 6 | return $resource; |
|
37 | } |
||
38 | |||
57 | } |