Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
n/a
0 / 0
Celemas\Router\getReflectionFunction
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Celemas\Router;
6
7use Closure;
8use ReflectionFunction;
9use ReflectionMethod;
10use ReflectionObject;
11
12/**
13 * @internal
14 * @param Closure|callable-object|callable-string $callable
15 */
16function 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}