Passed
Push — heiglandreas-patch-1 ( 8f4377 )
by Andreas
03:21
created

Twitter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 47.62%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 62
ccs 10
cts 21
cp 0.4762
rs 10
c 4
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequestTokenUri() 0 3 1
A getRequestTokenAccessUri() 0 3 1
A getName() 0 3 1
A getBaseUri() 0 3 1
A getAuthorizeUri() 0 3 1
A getIdentity() 0 30 1
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;
0 ignored issues
show
Bug introduced by
The type SocialConnect\Common\Entity\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class Twitter extends \SocialConnect\OAuth1\AbstractProvider
15
{
16
    const NAME = 'twitter';
17
18 1
    public function getBaseUri()
19
    {
20 1
        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
    public function getIdentity(AccessTokenInterface $accessToken)
47
    {
48
        $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
        $result = $this->request(
51
            'GET',
52
            'account/verify_credentials.json',
53
            [
54
                // String is expected because Twitter is awful
55
                'include_email' => 'true'
56
            ],
57
            $accessToken
58
        );
59
60
        $hydrator = new ArrayHydrator([
61
            'id' => 'id',
62
            'name' => 'fullname',
63
            'screen_name' => 'username',
64
            'profile_image_url_https' => 'pictureURL'
65
        ]);
66
67
        /** @var User $user */
68
        $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
        $user->emailVerified = true;
74
75
        return $user;
76
    }
77
}
78