GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Reflection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A firstParameterType() 0 14 3
A itemMatchesType() 0 8 2
1
<?php
2
3
namespace Spatie\Menu\Helpers;
4
5
use ReflectionFunction;
6
use ReflectionObject;
7
use ReflectionParameter;
8
use Spatie\Menu\Item;
9
10
class Reflection
11
{
12
    public static function firstParameterType(callable $callable): string
13
    {
14
        $reflection = is_object($callable)
15
            ? (new ReflectionObject($callable))->getMethod('__invoke')
16
            : new ReflectionFunction($callable);
17
18
        $parameters = $reflection->getParameters();
19
20
        $parameterTypes = array_map(function (ReflectionParameter $parameter) {
21
            return $parameter->getClass() ? $parameter->getClass()->name : null;
22
        }, $parameters);
23
24
        return $parameterTypes[0] ?? '';
25
    }
26
27
    public static function itemMatchesType(Item $item, string $type): bool
28
    {
29
        if ($type === '') {
30
            return true;
31
        }
32
33
        return $item instanceof $type;
34
    }
35
}
36