Completed
Push — master ( 0adf65...fea2cb )
by Litera
16s
created

BaseTestCase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

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