ReflectionTrait::getParentPrivatePropertyValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace steevanb\DoctrineEvents\Behavior;
4
5
trait ReflectionTrait
6
{
7
    /**
8
     * @param string $name
9
     * @param mixed $value
10
     * @return $this
11
     */
12
    protected function setParentPrivatePropertyValue($name, $value)
13
    {
14
        $reflectionProperty = new \ReflectionProperty(get_parent_class($this), $name);
15
        $reflectionProperty->setAccessible(true);
16
        $reflectionProperty->setValue($this, $value);
17
        $reflectionProperty->setAccessible(false);
18
19
        return $this;
20
    }
21
22
    /**
23
     * @param string $name
24
     * @return mixed
25
     */
26
    protected function getParentPrivatePropertyValue($name)
27
    {
28
        $reflectionProperty = new \ReflectionProperty(get_parent_class($this), $name);
29
        $reflectionProperty->setAccessible(true);
30
        $return = $reflectionProperty->getValue($this);
31
        $reflectionProperty->setAccessible(false);
32
33
        return $return;
34
    }
35
}
36