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 ( e68406...5eb45b )
by Freek
07:33
created

WelcomesNewUsers   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 21 5
1
<?php
2
3
namespace Spatie\WelcomeNotification;
4
5
use Carbon\Carbon;
6
use Closure;
7
8
class WelcomesNewUsers
9
{
10
    public function handle($request, Closure $next)
11
    {
12
13
        if (! $request->hasValidSignature()) {
14
            abort(401, 'The welcome link does not have a valid signature or is expired.');
15
        }
16
17
        if (! $request->user) {
18
            abort(401, 'Could not find a user to be welcomed.');
19
        }
20
21
        if (is_null($request->user->welcome_valid_until)) {
22
            return abort(401, 'The welcome link has already been used.');
23
        }
24
//dd(Carbon::createFromTimestamp($request->user->welcome_valid_until), $request->user->welcome_valid_until);
25
        if (Carbon::create($request->user->welcome_valid_until)->isPast()) {
26
            return abort(401, 'The welcome link has expired.');
27
        }
28
29
        return $next($request);
30
    }
31
}
32