| 1 |
<?php |
| 2 |
|
| 3 |
namespace LocateBinaries\Tests; |
| 4 |
|
| 5 |
class MethodInvoker |
| 6 |
{ |
| 7 |
public static function invoke($object, string $methodName, array $args=[]) { |
| 8 |
$privateMethod = self::getMethod(get_class($object), $methodName); |
| 9 |
|
| 10 |
return $privateMethod->invokeArgs($object, $args); |
| 11 |
} |
| 12 |
|
| 13 |
private static function getMethod(string $className, string $methodName) { |
| 14 |
$class = new \ReflectionClass($className); |
| 15 |
|
| 16 |
$method = $class->getMethod($methodName); |
| 17 |
$method->setAccessible(true); |
| 18 |
|
| 19 |
return $method; |
| 20 |
} |
| 21 |
} |
| 22 |
|