TwitterCC   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthURL() 0 2 1
A getAccessToken() 0 2 1
1
<?php
2
/**
3
 * Class TwitterCC
4
 *
5
 * @created      08.04.2018
6
 * @author       Smiley <[email protected]>
7
 * @copyright    2018 Smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\OAuth\Providers;
12
13
use chillerlan\OAuth\Core\{ClientCredentials, OAuth2Provider, ProviderException, AccessToken};
14
use Psr\Http\Message\UriInterface;
15
16
/**
17
 * @see https://dev.twitter.com/overview/api
18
 * @see https://developer.twitter.com/en/docs/basics/authentication/overview/application-only
19
 *
20
 * @todo: https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_token
21
 */
22
class TwitterCC extends OAuth2Provider implements ClientCredentials{
23
24
	protected const AUTH_ERRMSG                  = 'TwitterCC only supports Client Credentials Grant, use the Twitter OAuth1 class for authentication instead.';
25
26
	protected string $apiURL                     = 'https://api.twitter.com';
27
	protected ?string $clientCredentialsTokenURL = 'https://api.twitter.com/oauth2/token';
28
	protected ?string $userRevokeURL             = 'https://twitter.com/settings/applications';
29
	protected ?string $apiDocs                   = 'https://developer.twitter.com/en/docs/basics/authentication/overview/application-only';
30
	protected ?string $applicationURL            = 'https://developer.twitter.com/apps';
31
32
	/**
33
	 * @inheritdoc
34
	 * @throws \chillerlan\OAuth\Core\ProviderException
35
	 */
36
	public function getAuthURL(array $params = null, array $scopes = null):UriInterface{
37
		throw new ProviderException($this::AUTH_ERRMSG);
38
	}
39
40
	/**
41
	 * @inheritdoc
42
	 * @throws \chillerlan\OAuth\Core\ProviderException
43
	 */
44
	public function getAccessToken(string $code, string $state = null):AccessToken{
45
		throw new ProviderException($this::AUTH_ERRMSG);
46
	}
47
48
}
49