Completed
Pull Request — master (#16)
by Mischa
19:07 queued 12:02
created

AbstractAuthentication::getAccessToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the PHP SDK library for the Superdesk Content API.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace Superdesk\ContentApiSdk\API\Authentication;
16
17
use Superdesk\ContentApiSdk\Client\ClientInterface;
18
19
abstract class AbstractAuthentication implements AuthenticationInterface
20
{
21
    /**
22
     * URI for requesting and refreshing tokens.
23
     */
24
    const AUTHENTICATION_URI = 'oauth/token';
25
26
    /**
27
     * Refresh token grant type.
28
     */
29
    const REFRESH_GRANT_TYPE = 'refresh_token';
30
31
    /**
32
     * HTTP Client for making authentication requests.
33
     *
34
     * @var ClientInterface
35
     */
36
    protected $client;
37
38
    /**
39
     * Access token for the API.
40
     *
41
     * @var string
42
     */
43
    protected $accessToken;
44
45
    /**
46
     * Refresh token to referesh the access token.
47
     *
48
     * @var string
49
     */
50
    protected $refreshToken;
51
52
    /**
53
     * Client ID for the API.
54
     *
55
     * @var string
56
     */
57
    protected $clientId;
58
59
    /**
60
     * Base url for the api.
61
     *
62
     * @var string
63
     */
64
    protected $baseUrl;
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function __construct(ClientInterface $client)
70
    {
71
        $this->client = $client;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function getAccessToken()
78
    {
79
        return $this->accessToken;
80
    }
81
82
    /**
83
     * Gets the value of clientId.
84
     *
85
     * @return string
86
     */
87
    public function getClientId()
88
    {
89
        return $this->clientId;
90
    }
91
92
    /**
93
     * Sets the value of clientId.
94
     *
95
     * @param string $clientId Value to set
96
     *
97
     * @return self
98
     */
99
    public function setClientId($clientId)
100
    {
101
        $this->clientId = $clientId;
102
103
        return $this;
104
    }
105
106
    /**
107
     * Gets the value of baseUrl.
108
     *
109
     * @return mixed
110
     */
111
    public function getBaseUrl()
112
    {
113
        return $this->baseUrl;
114
    }
115
116
    /**
117
     * Sets the value of baseUrl.
118
     *
119
     * @param mixed $baseUrl Value to set
120
     *
121
     * @return self
122
     */
123
    public function setBaseUrl($baseUrl)
124
    {
125
        $this->baseUrl = $baseUrl;
126
127
        return $this;
128
    }
129
130
    /**
131
     * Returns the url where authentication tokens can be retrieved.
132
     *
133
     * @return string
134
     */
135
    public function getAuthenticationUrl()
136
    {
137
        return sprintf('%s/%s', rtrim($this->getBaseUrl(), '/ '), self::AUTHENTICATION_URI);
138
    }
139
}
140