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.

Issues (14)

src/Http/EnumRequest.php (3 issues)

1
<?php
2
3
namespace Spatie\Enum\Laravel\Http;
4
5
use Closure;
6
use Illuminate\Support\Arr;
7
use Spatie\Enum\Enum;
8
9
/**
10
 * @internal This class is only used to get mixed into \Illuminate\Http\Request
11
 *
12
 * @mixin \Illuminate\Http\Request
13
 */
14
final class EnumRequest
15
{
16
    public const REQUEST_ROUTE = 'route';
17
    public const REQUEST_QUERY = 'query';
18
    public const REQUEST_REQUEST = 'request';
19
20
    public function transformEnums(): Closure
21
    {
22
        return function (array $transformations): void {
23
            if (isset($transformations[EnumRequest::REQUEST_ROUTE])) {
24
                $route = $this->route();
0 ignored issues
show
The method route() does not exist on Spatie\Enum\Laravel\Http\EnumRequest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
                /** @scrutinizer ignore-call */ 
25
                $route = $this->route();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26
                /** @var string|Enum $enumClass */
27
                foreach ($transformations[EnumRequest::REQUEST_ROUTE] as $key => $enumClass) {
28
                    if (! $route->hasParameter($key)) {
29
                        continue;
30
                    }
31
32
                    $route->setParameter(
33
                        $key,
34
                        $enumClass::make($route->parameter($key))
35
                    );
36
                }
37
            }
38
39
            if (isset($transformations[EnumRequest::REQUEST_QUERY])) {
40
                /** @var string|Enum $enumClass */
41
                foreach ($transformations[EnumRequest::REQUEST_QUERY] as $key => $enumClass) {
42
                    if (! $this->query->has($key)) {
0 ignored issues
show
Bug Best Practice introduced by
The property query does not exist on Spatie\Enum\Laravel\Http\EnumRequest. Did you maybe forget to declare it?
Loading history...
43
                        continue;
44
                    }
45
46
                    $this->query->set(
47
                        $key,
48
                        $enumClass::make($this->query->get($key))
49
                    );
50
                }
51
            }
52
53
            if (isset($transformations[EnumRequest::REQUEST_REQUEST])) {
54
                /** @var string|Enum $enumClass */
55
                foreach ($transformations[EnumRequest::REQUEST_REQUEST] as $key => $enumClass) {
56
                    if (! $this->request->has($key)) {
0 ignored issues
show
Bug Best Practice introduced by
The property request does not exist on Spatie\Enum\Laravel\Http\EnumRequest. Did you maybe forget to declare it?
Loading history...
57
                        continue;
58
                    }
59
60
                    $this->request->set(
61
                        $key,
62
                        $enumClass::make($this->request->get($key))
63
                    );
64
                }
65
            }
66
67
            /** @var string|Enum $enumClass */
68
            foreach (Arr::except($transformations, [EnumRequest::REQUEST_ROUTE, EnumRequest::REQUEST_QUERY, EnumRequest::REQUEST_REQUEST]) as $key => $enumClass) {
69
                if (! isset($this[$key])) {
70
                    continue;
71
                }
72
73
                $this[$key] = $enumClass::make($this[$key]);
74
            }
75
        };
76
    }
77
}
78