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.
Completed
Push — master ( 504c99...f9b5ba )
by Sebastian
03:20
created

Reflection::itemMatchesType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace Spatie\Menu\Helpers;
4
5
use ReflectionFunction;
6
use ReflectionParameter;
7
use Spatie\Menu\Item;
8
9
class Reflection
10
{
11
    public static function firstParameterType(callable $callable): string
12
    {
13
        $reflection = new ReflectionFunction($callable);
14
15
        $parameterTypes = array_map(function (ReflectionParameter $parameter) {
16
            return $parameter->getClass() ? $parameter->getClass()->name : null;
17
        }, $reflection->getParameters());
18
19
        return $parameterTypes[0] ?? '';
20
    }
21
22
    public static function itemMatchesType(Item $item, string $type): bool
23
    {
24
        if ($type === '') {
25
            return true;
26
        }
27
28
        return $item instanceof $type;
29
    }
30
}
31