Kraken\Test\TUnit::callProtectedMethod PHP Method

callProtectedMethod() public method

Call protected method on a given object via reflection.
public callProtectedMethod ( object | string $objectOrClass, string $method, mixed[] $args = [] ) : mixed
$objectOrClass object | string
$method string
$args mixed[]
return mixed
    public function callProtectedMethod($objectOrClass, $method, $args = [])
    {
        $reflection = new ReflectionClass($objectOrClass);
        $reflectionMethod = $reflection->getMethod($method);
        $reflectionMethod->setAccessible(true);
        $reflectionTarget = is_object($objectOrClass) ? $objectOrClass : null;
        return $reflectionMethod->invokeArgs($reflectionTarget, $args);
    }