Conditions | 7 |
Paths | 12 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
20 | 6 | public static function from(callable $callable) |
|
21 | { |
||
22 | 6 | if (\is_string($callable) && \strpos($callable, '::')) { |
|
23 | 1 | $callable = \explode('::', $callable); |
|
24 | 6 | } elseif (!$callable instanceof Closure && \is_object($callable)) { |
|
25 | 1 | $callable = [$callable, '__invoke']; |
|
26 | } |
||
27 | |||
28 | /* @noinspection PhpUnhandledExceptionInspection */ |
||
29 | 6 | return $callable instanceof Closure || \is_string($callable) |
|
30 | 6 | ? new ReflectionFunction($callable) |
|
31 | 6 | : new ReflectionMethod($callable[0], $callable[1]); |
|
32 | } |
||
33 | } |
||
34 |