Passed
Push — master ( cfceb1...4bf73b )
by Koen
09:48
created

User::getEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Models;
6
7
use App\Events\User\Deleting;
8
use Illuminate\Database\Eloquent\Relations\HasMany;
9
use Illuminate\Foundation\Auth\User as Authenticatable;
10
use Illuminate\Notifications\Notifiable;
11
12
final class User extends Authenticatable
13
{
14
    use Notifiable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by App\Models\User.
Loading history...
15
16
    protected $fillable = [
17
        'name', 'email', 'password',
18
    ];
19
20
    protected $dispatchesEvents = [
21
        'deleting' => Deleting::class,
22
    ];
23
24
    private ?UserToken $currentToken = null;
25
26 6
    public function tokens(): HasMany
27
    {
28 6
        return $this->hasMany(UserToken::class);
29
    }
30
31 2
    public function setCurrentToken(UserToken $token)
32
    {
33 2
        $this->currentToken = $token;
34 2
    }
35
36 1
    public function getCurrentToken()
37
    {
38 1
        return $this->currentToken;
39
    }
40
41 1
    public function getEmail(): string
42
    {
43 1
        return $this->getAttributeValue('email');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getAttributeValue('email') could return the type boolean|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
44
    }
45
}
46