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

ReflectionFunctionFactory::createFromCallable()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 3
eloc 4
nc 4
nop 1
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
}