SendMobileVerificationNotification   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 6 3
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