SendMobileVerificationNotification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Fouladgar\MobileVerification\Listeners;
4
5
use Exception;
6
use Fouladgar\MobileVerification\Contracts\MustVerifyMobile;
7
use Fouladgar\MobileVerification\Tokens\TokenBrokerInterface;
8
use Illuminate\Auth\Events\Registered;
9
10
class SendMobileVerificationNotification
11
{
12
    /**
13
     * @var TokenBrokerInterface
14
     */
15
    protected $tokenBroker;
16
17
    /**
18
     * SendMobileVerificationNotification constructor.
19
     *
20
     * @param TokenBrokerInterface $tokenBroker
21
     */
22
    public function __construct(TokenBrokerInterface $tokenBroker)
23
    {
24
        $this->tokenBroker = $tokenBroker;
25
    }
26
27
    /**
28
     * Handle the event.
29
     *
30
     * @param Registered $event
31
     *
32
     * @throws Exception
33
     *
34
     * @return void
35
     */
36
    public function handle(Registered $event): void
37
    {
38
        $user = $event->user;
39
40
        if ($user instanceof MustVerifyMobile && ! $user->hasVerifiedMobile()) {
41
            $this->tokenBroker->sendToken($user);
42
        }
43
    }
44
}
45