Tools::callMethod()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineDatatable;
6
7
/**
8
 * Class Tools.
9
 */
10
class Tools
11
{
12
    /**
13
     * @param mixed   $obj
14
     * @param string  $name
15
     * @param mixed[] $args
16
     *
17
     * @return mixed
18
     *
19
     * @throws \ReflectionException
20
     */
21
    public function callMethod($obj, string $name, array $args = array())
22
    {
23
        $method = (new \ReflectionClass($obj))->getMethod($name);
24
        $method->setAccessible(true);
25
26
        return $method->invokeArgs(\is_object($obj) ? $obj : null, $args);
27
    }
28
}
29