Completed
Push — master ( 89be15...80fd60 )
by Igor
11:15
created

Twitter::email()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace app\parsers\oauth;
4
5
use yii\helpers\ArrayHelper;
6
7
/**
8
 * Parser for Twitter OAuth
9
 *
10
 * @property ClientInterface $client
11
 * @property array $profile
12
 * @property array $token
13
 */
14
class Twitter extends Parser
15
{
16
    /**
17
     * Get email
18
     *
19
     * @return string|null
20
     */
21
    public function email(): ?string
22
    {
23
        return ArrayHelper::getValue($this->profile, 'email');
24
    }
25
26
    /**
27
     * Get token info
28
     *
29
     * @return array
30
     */
31
    public function tokenData(): array
32
    {
33
        return [
34
            'profile_id' => ArrayHelper::getValue($this->profile, 'id'),
35
            'profile_url' => 'https://twitter.com/' . ArrayHelper::getValue($this->profile, 'screen_name'),
36
            'access_token' => ArrayHelper::getValue($this->token, 'oauth_token'),
37
            'access_token_secret' => ArrayHelper::getValue($this->token, 'oauth_token_secret')
38
        ];
39
    }
40
41
    /**
42
     * Get profile info
43
     *
44
     * @return array
45
     */
46
    public function profileData(): array
47
    {
48
        $photo = ArrayHelper::getValue($this->profile, 'profile_image_url');
49
        return [
50
            'full_name' => $this->profile['name'],
51
            'photo' => str_replace('_normal', '_400x400', $photo)
52
        ];
53
    }
54
}
55