Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function instantiate(string $class, array $data) |
||
12 | { |
||
13 | $object = new $class(); |
||
14 | $reflection = new \ReflectionClass($object); |
||
15 | |||
16 | foreach ($data as $key => $value) { |
||
17 | $property = $reflection->getProperty(Inflector::camelize($key)); |
||
18 | if (!$property->isPublic()) { |
||
19 | $property->setAccessible(true); |
||
20 | } |
||
21 | |||
22 | $property->setValue($object, $value); |
||
23 | } |
||
24 | |||
25 | return $object; |
||
26 | } |
||
27 | } |
||
28 |