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 ( a5fdf7...b97e0a )
by Pascal
01:06
created

PendingUserEmail   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A scopeForUser() 0 7 1
A activate() 0 12 1
A verificationUrl() 0 8 2
1
<?php
2
3
namespace ProtoneMedia\LaravelVerifyNewEmail;
4
5
use Illuminate\Auth\Events\Verified;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Facades\URL;
8
9
class PendingUserEmail extends Model
10
{
11
    /**
12
     * This model won't be updated.
13
     */
14
    const UPDATED_AT = null;
15
16
    /**
17
     * User relationship
18
     *
19
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
20
     */
21
    public function user()
22
    {
23
        return $this->morphTo('user');
24
    }
25
26
    /**
27
     * Scope for the user.
28
     *
29
     * @param $query
30
     * @param \Illuminate\Database\Eloquent\Model $user
31
     * @return void
32
     */
33
    public function scopeForUser($query, Model $user)
34
    {
35
        $query->where([
36
            $this->qualifyColumn('user_type') => get_class($user),
37
            $this->qualifyColumn('user_id')   => $user->getKey(),
38
        ]);
39
    }
40
41
    /**
42
     * Updates the associated user and removes all pending models with this email.
43
     *
44
     * @return void
45
     */
46
    public function activate()
47
    {
48
        return tap($this->user, function ($user) {
49
            $user->email = $this->email;
50
            $user->save();
51
            $user->markEmailAsVerified();
52
53
            static::whereEmail($this->email)->get()->each->delete();
54
55
            event(new Verified($user));
56
        });
57
    }
58
59
    /**
60
     * Creates a temporary signed URL to verify the pending email.
61
     *
62
     * @return string
63
     */
64
    public function verificationUrl(): string
65
    {
66
        return URL::temporarySignedRoute(
67
            config('verify-new-email.route') ?: 'pendingEmail.verify',
68
            now()->addMinutes(config('auth.verification.expire', 60)),
69
            ['token' => $this->token]
70
        );
71
    }
72
}
73