| Total Complexity | 9 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class OAuthProtocolHelper implements Interfaces\IOAuthProtocolHelper |
||
| 18 | { |
||
| 19 | private $oauthClient; |
||
| 20 | |||
| 21 | private $mediawikiWebServiceEndpoint; |
||
| 22 | |||
| 23 | private $authUrl; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * OAuthHelper constructor. |
||
| 27 | * |
||
| 28 | * @param string $oauthEndpoint |
||
| 29 | * @param string $consumerKey |
||
| 30 | * @param string $consumerSecret |
||
| 31 | * @param string $mediawikiWebServiceEndpoint |
||
| 32 | */ |
||
| 33 | public function __construct( |
||
| 34 | $oauthEndpoint, |
||
| 35 | $consumerKey, |
||
| 36 | $consumerSecret, |
||
| 37 | $mediawikiWebServiceEndpoint |
||
| 38 | ) { |
||
| 39 | $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
||
| 40 | |||
| 41 | $oauthClientConfig = new ClientConfig($oauthEndpoint); |
||
| 42 | $oauthClientConfig->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
||
| 43 | |||
| 44 | $this->oauthClient = new Client($oauthClientConfig); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritDoc |
||
| 49 | */ |
||
| 50 | public function getRequestToken() |
||
| 51 | { |
||
| 52 | /** @var Token $requestToken */ |
||
| 53 | list($authUrl, $requestToken) = $this->oauthClient->initiate(); |
||
| 54 | $this->authUrl = $authUrl; |
||
| 55 | return $requestToken; |
||
|
|
|||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @inheritDoc |
||
| 60 | */ |
||
| 61 | public function getAuthoriseUrl($requestToken) |
||
| 62 | { |
||
| 63 | return $this->authUrl; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @inheritDoc |
||
| 68 | */ |
||
| 69 | public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
||
| 70 | { |
||
| 71 | $requestToken = new Token($oauthRequestToken, $oauthRequestSecret); |
||
| 72 | |||
| 73 | return $this->oauthClient->complete($requestToken, $oauthVerifier); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @inheritDoc |
||
| 78 | */ |
||
| 79 | public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
||
| 80 | { |
||
| 81 | return $this->oauthClient->identify(new Token($oauthAccessToken, $oauthAccessSecret)); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @inheritDoc |
||
| 86 | */ |
||
| 87 | public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET') |
||
| 109 | } |
||
| 110 | } |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: