Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | n/a |
0 / 0 |
|
| Celemas\Router\getReflectionFunction | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Router; |
| 6 | |
| 7 | use Closure; |
| 8 | use ReflectionFunction; |
| 9 | use ReflectionMethod; |
| 10 | use ReflectionObject; |
| 11 | |
| 12 | /** |
| 13 | * @internal |
| 14 | * @param Closure|callable-object|callable-string $callable |
| 15 | */ |
| 16 | function getReflectionFunction( |
| 17 | callable $callable, |
| 18 | ): ReflectionFunction|ReflectionMethod { |
| 19 | if ($callable instanceof Closure) { |
| 20 | return new ReflectionFunction($callable); |
| 21 | } |
| 22 | |
| 23 | if (is_object($callable)) { |
| 24 | return new ReflectionObject($callable)->getMethod('__invoke'); |
| 25 | } |
| 26 | |
| 27 | return new ReflectionFunction($callable); |
| 28 | } |