InvokeInaccessibleMethodTrait::invokeMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
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