Passed
Push — master ( 188cdd...047a07 )
by Dmitry
02:45
created

ReflectionFunctionFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 0
cbo 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromCallable() 0 6 3
1
<?php
2
3
namespace Tonic\Component\Reflection;
4
5
/**
6
 * Static factory for reflection function.
7
 */
8
class ReflectionFunctionFactory
9
{
10
    /**
11
     * @param callable $callable
12
     *
13
     * @return \ReflectionFunctionAbstract
14
     */
15
    public static function createFromCallable(callable $callable)
16
    {
17
        return is_array($callable) && (count($callable) == 2)
18
            ? new \ReflectionMethod($callable[0], $callable[1])
19
            : new \ReflectionFunction($callable);
20
    }
21
}