Issues (10)

src/OAuth1/Provider/Twitter.php (1 issue)

1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
declare(strict_types=1);
7
8
namespace SocialConnect\OAuth1\Provider;
9
10
use SocialConnect\Common\ArrayHydrator;
11
use SocialConnect\Provider\AccessTokenInterface;
12
use SocialConnect\Common\Entity\User;
13
14
class Twitter extends \SocialConnect\OAuth1\AbstractProvider
15
{
16
    const NAME = 'twitter';
17
18 2
    public function getBaseUri()
19
    {
20 2
        return 'https://api.twitter.com/1.1/';
21
    }
22
23 1
    public function getAuthorizeUri()
24
    {
25 1
        return 'https://api.twitter.com/oauth/authenticate';
26
    }
27
28 1
    public function getRequestTokenUri()
29
    {
30 1
        return 'https://api.twitter.com/oauth/request_token';
31
    }
32
33 1
    public function getRequestTokenAccessUri()
34
    {
35 1
        return 'https://api.twitter.com/oauth/access_token';
36
    }
37
38 1
    public function getName()
39
    {
40 1
        return self::NAME;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function getIdentity(AccessTokenInterface $accessToken)
47
    {
48 1
        $this->consumerToken = $accessToken;
0 ignored issues
show
Documentation Bug introduced by
It seems like $accessToken of type SocialConnect\Provider\AccessTokenInterface is incompatible with the declared type SocialConnect\OAuth1\Token of property $consumerToken.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
50 1
        $result = $this->request(
51 1
            'GET',
52 1
            'account/verify_credentials.json',
53
            [
54
                // String is expected because Twitter is awful
55 1
                'include_email' => 'true'
56
            ],
57
            $accessToken
58
        );
59
60 1
        $hydrator = new ArrayHydrator([
61 1
            'id' => 'id',
62
            'name' => 'fullname',
63
            'screen_name' => 'username',
64
            'profile_image_url_https' => 'pictureURL'
65
        ]);
66
67
        /** @var User $user */
68 1
        $user = $hydrator->hydrate(new User(), $result);
69
70
        // When set to true email will be returned in the user objects as a string.
71
        // If the user does not have an email address on their account,
72
        // or if the email address is not verified, null will be returned.
73 1
        $user->emailVerified = true;
74
75 1
        return $user;
76
    }
77
}
78