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}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

Celemas\Router\getReflectionFunction
17    callable $callable,
18): ReflectionFunction|ReflectionMethod {
19    if ($callable instanceof Closure) {
20        return new ReflectionFunction($callable);
23    if (is_object($callable)) {
24        return new ReflectionObject($callable)->getMethod('__invoke');
27    return new ReflectionFunction($callable);