EmailConfirmationObserver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 29
rs 10
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A created() 0 8 2
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace App\Models\User;
11
12
use App\Models\User;
13
use Tymon\JWTAuth\Providers\JWT\JWTInterface;
14
use App\Notifications\ConfirmEmailNotification;
15
16
/**
17
 * Class EmailConfirmationObserver.
18
 */
19
class EmailConfirmationObserver
20
{
21
    /**
22
     * @var JWTInterface
23
     */
24
    private $jwt;
25
26
    /**
27
     * EmailConfirmationObserver constructor.
28
     *
29
     * @param JWTInterface $jwt
30
     */
31
    public function __construct(JWTInterface $jwt)
32
    {
33
        $this->jwt = $jwt;
34
    }
35
36
    /**
37
     * @param User $user
38
     */
39
    public function created(User $user)
40
    {
41
        if (! $user->is_confirmed) {
42
            $confirmation = new ConfirmEmailNotification($user, $this->jwt);
43
44
            $user->notify($confirmation);
45
        }
46
    }
47
}
48