Passed
Push — master ( e72ba5...492fde )
by Alexander
10:28
created

TestCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 33
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Profiler\Tests;
6
7
use Yiisoft\Profiler\Tests\Logger\ArrayLogger;
8
9
abstract class TestCase extends \PHPUnit\Framework\TestCase
10
{
11
    protected ArrayLogger $logger;
12
13
    protected function setUp(): void
14
    {
15
        parent::setUp();
16
17
        $this->logger = new ArrayLogger();
18
    }
19
20
    /**
21
     * Invokes a inaccessible method.
22
     *
23
     * @param object $object
24
     * @param string $method
25
     * @param array $args
26
     * @param bool $revoke whether to make method inaccessible after execution
27
     *
28
     * @return mixed
29
     */
30
    protected function invokeMethod($object, $method, $args = [], $revoke = true)
31
    {
32
        $reflection = new \ReflectionObject($object);
33
        $method = $reflection->getMethod($method);
34
        $method->setAccessible(true);
35
        $result = $method->invokeArgs($object, $args);
36
37
        if ($revoke) {
38
            $method->setAccessible(false);
39
        }
40
41
        return $result;
42
    }
43
}
44