ReflectionTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setParentPrivatePropertyValue() 0 9 1
A getParentPrivatePropertyValue() 0 9 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