MustVerifyMobile::sendMobileVerifierNotification()   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\Concerns;
4
5
use Fouladgar\MobileVerification\Notifications\VerifyMobile as VerifyMobileNotification;
6
use Illuminate\Config\Repository;
7
8
trait MustVerifyMobile
9
{
10
    /**
11
     * Determine if the user has verified their mobile number.
12
     */
13
    public function hasVerifiedMobile(): bool
14
    {
15
        return null !== $this->mobile_verified_at;
16
    }
17
18
    /**
19
     * Mark the given user's mobile as verified.
20
     */
21
    public function markMobileAsVerified(): bool
22
    {
23
        return $this->forceFill(['mobile_verified_at' => $this->freshTimestamp()])->save();
0 ignored issues
show
Bug introduced by
It seems like forceFill() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->/** @scrutinizer ignore-call */ forceFill(['mobile_verified_at' => $this->freshTimestamp()])->save();
Loading history...
Bug introduced by
It seems like freshTimestamp() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->forceFill(['mobile_verified_at' => $this->/** @scrutinizer ignore-call */ freshTimestamp()])->save();
Loading history...
24
    }
25
26
    /**
27
     * Send the mobile verification notification.
28
     */
29
    public function sendMobileVerifierNotification(string $token): void
30
    {
31
        $this->notify(new VerifyMobileNotification($token));
0 ignored issues
show
Bug introduced by
It seems like notify() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        $this->/** @scrutinizer ignore-call */ 
32
               notify(new VerifyMobileNotification($token));
Loading history...
32
    }
33
34
    /**
35
     * Get the mobile number that should be used for verification.
36
     */
37
    public function getMobileForVerification(): string
38
    {
39
        return $this->{$this->getMobileField()};
40
    }
41
42
    /**
43
     * Get the recipients of the given message.
44
     *
45
     * @return mixed
46
     */
47
    public function routeNotificationForVerificationMobile(): string
48
    {
49
        return $this->{$this->getMobileField()};
50
    }
51
52
    /**
53
     * @return Repository|mixed
54
     */
55
    private function getMobileField()
56
    {
57
        return config('mobile_verifier.mobile_column', 'mobile');
58
    }
59
}
60