Completed
Push — master ( 65f314...a56b5d )
by Paweł
08:26
created

ExternalOauthResourceOwner::getEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SWP\Bundle\CoreBundle\Security\Provider;
4
5
use League\OAuth2\Client\Provider\GenericResourceOwner;
6
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
7
8
class ExternalOauthResourceOwner extends GenericResourceOwner
9
{
10
    use ArrayAccessorTrait;
11
12
    protected $response;
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function __construct(array $response = [])
18
    {
19
        $this->response = $response;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getId(): string
26
    {
27
        return $this->getValueByKey($this->response, 'sub');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getEmail(): string
34
    {
35
        // Normalize email address
36
        return \strtolower($this->getValueByKey($this->response, 'email'));
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getName(): string
43
    {
44
        return $this->getValueByKey($this->response, 'name');
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function toArray(): array
51
    {
52
        return $this->response;
53
    }
54
}
55