Completed
Pull Request — master (#22)
by
unknown
02:34
created

PrivateMethodCaller   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A callMethod() 0 8 1
1
<?php
2
3
namespace MovingImage\Client\VMPro\Util;
4
5
/**
6
 * Trait PrivateMethodCaller.
7
 *
8
 * @author Robert Szeker <[email protected]>
9
 */
10
trait PrivateMethodCaller
11
{
12
    /**
13
     * Used to call and test private or protected methods from a given object.
14
     *
15
     * @param object $obj
16
     * @param string $methodName
17
     * @param array  $arguments
18
     *
19
     * @return mixed
20
     */
21
    public function callMethod($obj, $methodName, $arguments)
22
    {
23
        $reflector = new \ReflectionObject($obj);
24
        $method = $reflector->getMethod($methodName);
25
        $method->setAccessible(true);
26
27
        return $method->invoke($obj, ...$arguments);
28
    }
29
}
30