| Conditions | 4 |
| Paths | 6 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public static function hydrate(array $item, $object) |
||
| 24 | { |
||
| 25 | if (\is_string($object)) { |
||
| 26 | $instance = new $object(); |
||
| 27 | } else { |
||
| 28 | $instance = $object; |
||
| 29 | } |
||
| 30 | |||
| 31 | foreach ($item as $key => $value) { |
||
| 32 | $method = 'set' . self::studly($key); |
||
| 33 | |||
| 34 | if (method_exists($instance, $method)) { |
||
| 35 | $instance->{$method}($value); |
||
| 36 | } else { |
||
| 37 | $property = self::camel($key); |
||
| 38 | $instance->{$property} = $value; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return $instance; |
||
| 43 | } |
||
| 74 |