InvokeInaccessibleMethodTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A invokeMethod() 0 8 1
1
<?php
2
3
namespace Stp\SndApi\Common\Test;
4
5
trait InvokeInaccessibleMethodTrait
6
{
7
    /**
8
     * Call protected/private method of a class.
9
     *
10
     * @param object $object    Instantiated object that we will run method on.
11
     * @param string $methodName Method name to call
12
     * @param array  $parameters Array of parameters to pass into method.
13
     *
14
     * @return mixed Method return.
15
     */
16
    public function invokeMethod($object, $methodName, array $parameters = array())
17
    {
18
        $reflection = new \ReflectionClass(get_class($object));
19
        $method = $reflection->getMethod($methodName);
20
        $method->setAccessible(true);
21
22
        return $method->invokeArgs($object, $parameters);
23
    }
24
}
25