Completed
Pull Request — master (#3)
by Rougin
02:24
created

MagicMethodHelper::call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Rougin\Describe;
4
5
/**
6
 * Magic Method Helper
7
 *
8
 * @package Describe
9
 * @author  Rougin Royce Gutib <[email protected]>
10
 */
11
class MagicMethodHelper
12
{
13
    /**
14
     * Calls methods from the specified object in underscore case.
15
     *
16
     * @param  object $object
17
     * @param  string $method
18
     * @param  mixed  parameters
19
     * @return mixed
20
     */
21 3
    public static function call($object, $method, $parameters)
22
    {
23 3
        $method = \Doctrine\Common\Inflector\Inflector::camelize($method);
24 3
        $result = $object;
25
26 3
        if (method_exists($object, $method)) {
27 3
            $result = call_user_func_array([ $object, $method ], $parameters);
28 3
        }
29
30 3
        return $result;
31
    }
32
}
33