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.

WelcomesNewUsers   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 20 5
1
<?php
2
3
namespace Spatie\WelcomeNotification;
4
5
use Carbon\Carbon;
6
use Closure;
7
use Symfony\Component\HttpFoundation\Response;
8
9
class WelcomesNewUsers
10
{
11
    public function handle($request, Closure $next)
12
    {
13
        if (! $request->hasValidSignature()) {
14
            abort(Response::HTTP_FORBIDDEN, 'The welcome link does not have a valid signature or is expired.');
15
        }
16
17
        if (! $request->user) {
18
            abort(Response::HTTP_FORBIDDEN, 'Could not find a user to be welcomed.');
19
        }
20
21
        if (is_null($request->user->welcome_valid_until)) {
22
            return abort(Response::HTTP_FORBIDDEN, 'The welcome link has already been used.');
23
        }
24
25
        if (Carbon::create($request->user->welcome_valid_until)->isPast()) {
0 ignored issues
show
Bug introduced by
It seems like isPast() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
26
            return abort(Response::HTTP_FORBIDDEN, 'The welcome link has expired.');
27
        }
28
29
        return $next($request);
30
    }
31
}
32