Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 05804d...4c0d79 )
by Dan
20s queued 16s
created

TestUtils::getPrivateMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php declare(strict_types=1);
2
3
namespace SmrTest;
4
5
class TestUtils {
6
7
	/**
8
	 * Get a private or protected method for testing/documentation purposes.
9
	 * Note that this function should only be used as a last resort! Its use
10
	 * indicates that the input class is a good candidate for refactoring.
11
	 *
12
	 * How to use for MyClass->foo():
13
	 *    $cls = new MyClass();
14
	 *    $foo = SmrTest\TestUtils::getPrivateMethod($cls, 'foo');
15
	 *    $foo->invoke($cls, $args, ...);
16
	 *
17
	 * @param object $obj The instance of your class
18
	 * @param string $name The name of your private/protected method
19
	 * @return \ReflectionMethod The method you want to test
20
	 */
21
	public static function getPrivateMethod(object $obj, string $name) : \ReflectionMethod {
22
		$class = new \ReflectionClass($obj);
23
		$method = $class->getMethod($name);
24
		$method->setAccessible(true);
25
		return $method;
26
	}
27
28
}
29