GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Bookingsync   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 2
dl 0
loc 91
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A urlAuthorize() 0 4 1
A urlAccessToken() 0 4 1
A urlUserDetails() 0 4 1
A userDetails() 0 14 4
A userUid() 0 5 3
A userEmail() 0 5 3
A userScreenName() 0 5 3
1
<?php namespace Bookingsync\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Provider\AbstractProvider;
4
use League\OAuth2\Client\Entity\User;
5
use League\OAuth2\Client\Token\AccessToken;
6
7
class Bookingsync extends AbstractProvider
8
{
9
    public $scopeSeparator = ' ';
10
    public $scopes = ['public', 'bookings_write_owned', 'bookings_read', 'bookings_write',
11
                      'clients_read', 'clients_write',
12
                      'inquiries_read', 'inquiries_write',
13
                      'payments_read', 'payments_write',
14
                      'rates_read', 'rates_write',
15
                      'rentals_read', 'rentals_write',
16
                      'reviews_write'];
17
    public $responseType = 'json';
18
    public $authorizationHeader = 'Bearer';
19
    public $version = 'v3';
20
21
    /**
22
     * Get the URL that this provider uses to begin authorization.
23
     *
24
     * @return string
25
     */
26
    public function urlAuthorize()
27
    {
28
        return 'https://www.bookingsync.com/oauth/authorize';
29
    }
30
31
    /**
32
     * Get the URL that this provider users to request an access token.
33
     *
34
     * @return string
35
     */
36
    public function urlAccessToken()
37
    {
38
        return 'https://www.bookingsync.com/oauth/token';
39
    }
40
41
    /**
42
     * Get the URL that this provider uses to request user details.
43
     *
44
     * Since this URL is typically an authorized route, most providers will require you to pass the access_token as
45
     * a parameter to the request. For example, the google url is:
46
     *
47
     * 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token='.$token
48
     *
49
     * @param AccessToken $token
50
     * @return string
51
     */
52
    public function urlUserDetails(AccessToken $token)
53
    {
54
        return 'https://www.bookingsync.com/api/'.$this->version.'/accounts';
55
    }
56
57
    /**
58
     * Given an object response from the server, process the user details into a format expected by the user
59
     * of the client.
60
     *
61
     * @param object $response
62
     * @param AccessToken $token
63
     * @return mixed
64
     */
65
    public function userDetails($response, AccessToken $token)
66
    {
67
        $response = current($response->accounts);
68
69
        $user = new User();
70
71
        $user->exchangeArray([
72
            'uid' => isset($response->id) ? $response->id : null,
73
            'name' => isset($response->business_name) ? $response->business_name : null,
74
            'email' => isset($response->email) ? $response->email : null
75
        ]);
76
77
        return $user;
78
    }
79
80
    public function userUid($response, AccessToken $token)
81
    {
82
        $response = current($response->accounts);
83
        return isset($response->id) && $response->id ? $response->id : null;
84
    }
85
86
    public function userEmail($response, AccessToken $token)
87
    {
88
        $response = current($response->accounts);
89
        return isset($response->email) && $response->email ? $response->email : null;
90
    }
91
92
    public function userScreenName($response, AccessToken $token)
93
    {
94
        $response = current($response->accounts);
95
        return isset($response->business_name) && $response->business_name ? $response->business_name : null;
96
    }
97
}
98