Completed
Push — master ( 06b292...adafac )
by Nicolai
02:22
created

AccessesHiddenMethods::getProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\Util;
5
6
use ReflectionClass;
7
8
9
/**
10
 * Trait AccessesHiddenMethods
11
 *
12
 * @package SmartWeb\Testing\Util
13
 */
14
trait AccessesHiddenMethods
15
{
16
    
17
    /**
18
     * @param object $object
19
     * @param string $method
20
     * @param array  ...$parameters
21
     *
22
     * @return mixed
23
     */
24
    private function invokeMethod($object, string $method, ...$parameters)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
25
    {
26
        $reflection = new ReflectionClass(get_class($object));
27
        $method = $reflection->getMethod($method);
28
        $method->setAccessible(true);
29
        
30
        return $method->invokeArgs($object, $parameters);
31
    }
32
    
33
    /**
34
     * @param object $object
35
     * @param string $property
36
     *
37
     * @return mixed
38
     */
39
    private function getProperty($object, string $property)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
40
    {
41
        $reflection = new ReflectionClass(get_class($object));
42
        $property = $reflection->getProperty($property);
43
        $property->setAccessible(true);
44
        
45
        return $property->getValue($object);
46
    }
47
}