Draugiem::getResourceOwnerDetailsUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Oauth\Client\Provider\Draugiem;
4
5
use League\OAuth2\Client\Provider\AbstractProvider;
6
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
7
use League\OAuth2\Client\Token\AccessToken;
8
use Psr\Http\Message\ResponseInterface;
9
10
class Draugiem extends AbstractProvider
11
{
12
    /**
13
     * Draugiem.lv API URL
14
     */
15
    const API_URL = 'http://api.draugiem.lv/json/';
16
17
    /**
18
     * Draugiem.lv passport login URL
19
     */
20
    const LOGIN_URL = 'https://api.draugiem.lv/authorize/';
21
22
    /**
23
     * Timeout in seconds for session_check requests
24
     */
25
    const SESSION_CHECK_TIMEOUT = 180;
26
27
    /**
28
     * @param array $options
29
     * @param array $collaborators
30
     *
31
     * @throws \InvalidArgumentException
32
     */
33
    public function __construct(array $options = [], array $collaborators = [])
34
    {
35
        parent::__construct($options, $collaborators);
36
    }
37
38
    public function getBaseAuthorizationUrl()
39
    {
40
        return static::LOGIN_URL;
41
    }
42
43
    public function getBaseAccessTokenUrl(array $params = [])
44
    {
45
        return static::API_URL;
46
    }
47
48
    public function getDefaultScopes()
49
    {
50
        return [];
51
    }
52
53
    public function getClientSecret()
54
    {
55
        return $this->clientSecret;
56
    }
57
58
    public function getClientId()
59
    {
60
        return $this->clientId;
61
    }
62
63
    public function getRedirectUri()
64
    {
65
        return $this->redirectUri;
66
    }
67
68
    public function getResourceOwnerDetailsUrl(AccessToken $token)
69
    {
70
    }
71
72
    protected function createResourceOwner(array $response, AccessToken $token)
73
    {
74
        return new DraugiemUser($response);
75
    }
76
77
    protected function checkResponse(ResponseInterface $response, $data)
78
    {
79
        if (!empty($data['error'])) {
80
            throw new IdentityProviderException('error_draugiem_bad_response', $data['error']['code'], $response->getBody());
81
        }
82
    }
83
}
84