|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Risan\OAuth1; |
|
4
|
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
|
6
|
|
|
use Risan\OAuth1\Request\RequestFactoryInterface; |
|
7
|
|
|
use Risan\OAuth1\Credentials\TemporaryCredentials; |
|
8
|
|
|
use Risan\OAuth1\Credentials\CredentialsFactoryInterface; |
|
9
|
|
|
|
|
10
|
|
|
class OAuth1 implements OAuth1Interface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* The HttpClientInterface instance. |
|
14
|
|
|
* |
|
15
|
|
|
* @var \Risan\OAuth1\HttpClientInterface |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $httpClient; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* The RequestFactoryInterface instance. |
|
21
|
|
|
* |
|
22
|
|
|
* @var \Risan\OAuth1\Request\RequestFactoryInterface |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $requestFactory; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The CredentialsFactoryInterface instance. |
|
28
|
|
|
* |
|
29
|
|
|
* @var \Risan\OAuth1\Credentials\CredentialsFactoryInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $credentialsFactory; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Create a new OAuth1 instance. |
|
35
|
|
|
* |
|
36
|
|
|
* @param \Risan\OAuth1\HttpClientInterface $httpClient |
|
37
|
|
|
* @param \Risan\OAuth1\Request\RequestFactoryInterface $request |
|
|
|
|
|
|
38
|
|
|
* @param \Risan\OAuth1\Credentials\CredentialsFactoryInterface $credentialsFactory |
|
39
|
|
|
*/ |
|
40
|
6 |
|
public function __construct(HttpClientInterface $httpClient, RequestFactoryInterface $requestFactory, CredentialsFactoryInterface $credentialsFactory) |
|
41
|
|
|
{ |
|
42
|
6 |
|
$this->httpClient = $httpClient; |
|
43
|
6 |
|
$this->requestFactory = $requestFactory; |
|
44
|
6 |
|
$this->credentialsFactory = $credentialsFactory; |
|
45
|
6 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* {@inheritDoc} |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function getHttpClient() |
|
51
|
|
|
{ |
|
52
|
1 |
|
return $this->httpClient; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritDoc} |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public function getRequestFactory() |
|
59
|
|
|
{ |
|
60
|
1 |
|
return $this->requestFactory; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritDoc} |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function getCredentialsFactory() |
|
67
|
|
|
{ |
|
68
|
1 |
|
return $this->credentialsFactory; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritDoc} |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public function getTemporaryCredentials() |
|
75
|
|
|
{ |
|
76
|
1 |
|
$response = $this->httpClient->send($this->requestFactory->createForTemporaryCredentials()); |
|
77
|
|
|
|
|
78
|
1 |
|
return $this->credentialsFactory->createTemporaryCredentialsFromResponse($response); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritDoc} |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function buildAuthorizationUri(TemporaryCredentials $temporaryCredentials) |
|
85
|
|
|
{ |
|
86
|
1 |
|
return (string) $this->requestFactory->buildAuthorizationUri($temporaryCredentials); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritDoc} |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verificationCode) |
|
93
|
|
|
{ |
|
94
|
|
|
if ($temporaryCredentials->getIdentifier() !== $temporaryIdentifier) { |
|
95
|
|
|
throw new InvalidArgumentException('The given temporary identifier does not match the temporary credentials.'); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$response = $this->httpClient->send( |
|
99
|
|
|
$this->requestFactory->createForTemporaryCredentials($temporaryCredentials, $verificationCode) |
|
|
|
|
|
|
100
|
|
|
); |
|
101
|
|
|
|
|
102
|
|
|
return $response; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.