We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 1 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 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 { |
||
| 29 |