Yandex::getEmail()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 4
nc 4
nop 0
crap 20
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-usuario project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\User\AuthClient;
13
14
use Da\User\Contracts\AuthClientInterface;
15
use Yii;
16
use yii\authclient\clients\Yandex as BaseYandex;
17
18
class Yandex extends BaseYandex implements AuthClientInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getEmail()
24
    {
25
        $emails = isset($this->getUserAttributes()['emails'])
26
            ? $this->getUserAttributes()['emails']
27
            : null;
28
29
        if ($emails !== null && isset($emails[0])) {
30
            return $emails[0];
31
        }
32
33
        return null;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getUsername()
40
    {
41
        return isset($this->getUserAttributes()['login'])
42
            ? $this->getUserAttributes()['login']
43
            : null;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function defaultTitle()
50
    {
51
        return Yii::t('usuario', 'Yandex');
52
    }
53
}
54