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

MagicMethodHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 11 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