Completed
Push — master ( 66742c...e4d7d0 )
by Joseph
01:03
created

Identity::getAuthIdentifierName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace STS\SocialiteAuth;
4
5
use Illuminate\Contracts\Auth\Authenticatable;
6
use Illuminate\Contracts\Support\Arrayable;
7
use Laravel\Socialite\Contracts\User;
8
9
class Identity implements Authenticatable, Arrayable
10
{
11
    public $name;
12
    public $email;
13
    public $avatar;
14
15
    public static function fromSocialite(User $user)
16
    {
17
        $instance = new static;
18
19
        $instance->name = $user->getName();
20
        $instance->email = $user->getEmail();
21
        $instance->avatar = $user->getAvatar();
22
23
        return $instance;
24
    }
25
26
    public static function restore(array $details)
27
    {
28
        $instance = new static;
29
30
        $instance->name = $details['name'];
31
        $instance->email = $details['email'];
32
        $instance->avatar = $details['avatar'];
33
34
        return $instance;
35
    }
36
37
    public function getAuthIdentifier()
38
    {
39
        return $this->email;
40
    }
41
42
    public function getAuthIdentifierName()
43
    {
44
        return 'email';
45
    }
46
47
    public function getAuthPassword()
48
    {
49
    }
50
51
    public function getRememberToken()
52
    {
53
    }
54
55
    public function getRememberTokenName()
56
    {
57
    }
58
59
    public function setRememberToken($value)
60
    {
61
    }
62
63
    public function toArray()
64
    {
65
        return [
66
            'name' => $this->name,
67
            'email' => $this->email,
68
            'avatar' => $this->avatar
69
        ];
70
    }
71
}
72