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