|
@@ 107-114 (lines=8) @@
|
| 104 |
|
$object = $reflectionClass->newInstanceWithoutConstructor(); |
| 105 |
|
$reflectionObject = new \ReflectionObject($object); |
| 106 |
|
|
| 107 |
|
foreach ($rule->getMap() as $property => $key) { |
| 108 |
|
$reflectionProperty = $reflectionObject->getProperty($property); |
| 109 |
|
$reflectionProperty->setAccessible(true); |
| 110 |
|
|
| 111 |
|
$constructor = $rule->getConstructor($property); |
| 112 |
|
|
| 113 |
|
$reflectionProperty->setValue($object, is_callable($constructor) ? $constructor($data[$key]) : $data[$key]); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
return $object; |
| 117 |
|
} |
|
@@ 131-140 (lines=10) @@
|
| 128 |
|
$reflectionObject = new \ReflectionObject($object); |
| 129 |
|
$result = []; |
| 130 |
|
|
| 131 |
|
foreach ($rule->getMap() as $property => $key) { |
| 132 |
|
$reflectionProperty = $reflectionObject->getProperty($property); |
| 133 |
|
$reflectionProperty->setAccessible(true); |
| 134 |
|
|
| 135 |
|
$serializer = $rule->getSerializer($property); |
| 136 |
|
|
| 137 |
|
$result[$key] = is_callable($serializer) |
| 138 |
|
? $serializer($reflectionProperty->getValue($object)) |
| 139 |
|
: $reflectionProperty->getValue($object); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
return $result; |
| 143 |
|
} |