Eventbrite   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 4
dl 0
loc 80
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseAuthorizationUrl() 0 4 1
A getBaseAccessTokenUrl() 0 4 1
A getResourceOwnerDetailsUrl() 0 4 1
A getDefaultScopes() 0 4 1
A checkResponse() 0 10 4
A createResourceOwner() 0 4 1
1
<?php namespace Stevenmaguire\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Provider\AbstractProvider;
4
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
5
use League\OAuth2\Client\Token\AccessToken;
6
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
7
use Psr\Http\Message\ResponseInterface;
8
9
class Eventbrite extends AbstractProvider
10
{
11
    use BearerAuthorizationTrait;
12
13
    /**
14
     * Get authorization url to begin OAuth flow
15
     *
16
     * @return string
17
     */
18 9
    public function getBaseAuthorizationUrl()
19
    {
20 9
        return 'https://www.eventbrite.com/oauth/authorize';
21
    }
22
23
    /**
24
     * Get access token url to retrieve token
25
     *
26
     * @return string
27
     */
28 12
    public function getBaseAccessTokenUrl(array $params)
29
    {
30 12
        return 'https://www.eventbrite.com/oauth/token';
31
    }
32
33
    /**
34
     * Get provider url to fetch user details
35
     *
36
     * @param  AccessToken $token
37
     *
38
     * @return string
39
     */
40 3
    public function getResourceOwnerDetailsUrl(AccessToken $token)
41
    {
42 3
        return 'https://www.eventbrite.com/json/user_get';
43
    }
44
45
    /**
46
     * Get the default scopes used by this provider.
47
     *
48
     * This should not be a complete list of all scopes, but the minimum
49
     * required for the provider user interface!
50
     *
51
     * @return array
52
     */
53 6
    protected function getDefaultScopes()
54
    {
55 6
        return [];
56
    }
57
58
    /**
59
     * Check a provider response for errors.
60
     *
61
     * @throws IdentityProviderException
62
     * @param  ResponseInterface $response
63
     * @param  string $data Parsed response data
64
     * @return void
65
     */
66 9
    protected function checkResponse(ResponseInterface $response, $data)
67
    {
68 9
        if (isset($data['error'])) {
69 3
            throw new IdentityProviderException(
70 3
                $data['error_description'] ?: $response->getReasonPhrase(),
71 3
                $data['status_code'] ?: $response->getStatusCode(),
72
                $response
0 ignored issues
show
Documentation introduced by
$response is of type object<Psr\Http\Message\ResponseInterface>, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73 2
            );
74
        }
75 6
    }
76
77
    /**
78
     * Generate a user object from a successful user details request.
79
     *
80
     * @param object $response
81
     * @param AccessToken $token
82
     * @return League\OAuth2\Client\Provider\ResourceOwnerInterface
83
     */
84 3
    protected function createResourceOwner(array $response, AccessToken $token)
85
    {
86 3
        return new EventbriteResourceOwner($response);
87
    }
88
}
89