@@ 29-45 (lines=17) @@ | ||
26 | * @param object $object |
|
27 | * @param mixed $value |
|
28 | */ |
|
29 | public function setValue($object, $value) |
|
30 | { |
|
31 | if (interface_exists('Doctrine\Common\Persistence\Proxy') && $object instanceof Proxy) { |
|
32 | $class = (new \ReflectionClass($object))->getParentClass()->name; |
|
33 | } else { |
|
34 | $class = get_class($object); |
|
35 | } |
|
36 | ||
37 | try { |
|
38 | $reflectionProperty = new \ReflectionProperty($class, $this->property); |
|
39 | } catch (\ReflectionException $e) { |
|
40 | throw DeserializerLogicException::createMissingProperty($class, $this->property); |
|
41 | } |
|
42 | ||
43 | $reflectionProperty->setAccessible(true); |
|
44 | $reflectionProperty->setValue($object, $value); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * @param object $object |
|
@@ 52-69 (lines=18) @@ | ||
49 | * |
|
50 | * @return mixed |
|
51 | */ |
|
52 | public function getValue($object) |
|
53 | { |
|
54 | if (interface_exists('Doctrine\Common\Persistence\Proxy') && $object instanceof Proxy) { |
|
55 | $class = (new \ReflectionClass($object))->getParentClass()->name; |
|
56 | } else { |
|
57 | $class = get_class($object); |
|
58 | } |
|
59 | ||
60 | try { |
|
61 | $reflectionProperty = new \ReflectionProperty($class, $this->property); |
|
62 | } catch (\ReflectionException $e) { |
|
63 | throw DeserializerLogicException::createMissingProperty($class, $this->property); |
|
64 | } |
|
65 | ||
66 | $reflectionProperty->setAccessible(true); |
|
67 | ||
68 | return $reflectionProperty->getValue($object); |
|
69 | } |
|
70 | } |
|
71 |