Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
55.56% |
5 / 9 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
SpecialPageOAuthUrl | |
55.56% |
5 / 9 |
|
50.00% |
1 / 2 |
3.79 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getValue | |
42.86% |
3 / 7 |
|
0.00% |
0 / 1 |
2.75 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\WikibaseManifest; |
4 | |
5 | use Config; |
6 | use MediaWiki\Extension\OAuth\Backend\Utils; |
7 | use MediaWiki\Extension\OAuth\Frontend\SpecialPages\SpecialMWOAuthConsumerRegistration; |
8 | use WikiMap; |
9 | |
10 | class SpecialPageOAuthUrl implements OAuthUrl { |
11 | |
12 | private Config $config; |
13 | private $specialPage; |
14 | |
15 | public function __construct( |
16 | Config $config, |
17 | ?SpecialMWOAuthConsumerRegistration $specialPage = null |
18 | ) { |
19 | $this->config = $config; |
20 | $this->specialPage = $specialPage; |
21 | } |
22 | |
23 | public function getValue(): string { |
24 | if ( Utils::isCentralWiki() ) { |
25 | $url = $this->specialPage->getPageTitle()->getFullURL(); |
26 | } else { |
27 | $url = WikiMap::getForeignURL( |
28 | $this->config->get( 'MWOAuthCentralWiki' ), |
29 | 'Special:OAuthConsumerRegistration' |
30 | ); |
31 | } |
32 | return $url; |
33 | } |
34 | } |