EmailConfirmationObserver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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