Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| OAuthUrlFactory | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getOAuthUrl | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\WikibaseManifest; |
| 4 | |
| 5 | use Config; |
| 6 | use ExtensionRegistry; |
| 7 | use MediaWiki\SpecialPage\SpecialPageFactory; |
| 8 | |
| 9 | class OAuthUrlFactory { |
| 10 | |
| 11 | private const OAUTH_EXT_NAME = 'OAuth'; |
| 12 | private const OAUTH_PAGE_NAME = 'OAuthConsumerRegistration'; |
| 13 | private Config $config; |
| 14 | private $registry; |
| 15 | private $specialPageFactory; |
| 16 | |
| 17 | public function __construct( |
| 18 | Config $config, |
| 19 | ExtensionRegistry $registry, |
| 20 | SpecialPageFactory $specialPageFactory |
| 21 | ) { |
| 22 | $this->config = $config; |
| 23 | $this->registry = $registry; |
| 24 | $this->specialPageFactory = $specialPageFactory; |
| 25 | } |
| 26 | |
| 27 | public function getOAuthUrl(): OAuthUrl { |
| 28 | if ( $this->registry->isLoaded( self::OAUTH_EXT_NAME ) ) { |
| 29 | $specialPage = $this->specialPageFactory->getPage( self::OAUTH_PAGE_NAME ); |
| 30 | return new SpecialPageOAuthUrl( |
| 31 | $this->config, |
| 32 | $specialPage |
| 33 | ); |
| 34 | } |
| 35 | return new NullOAuthUrl(); |
| 36 | } |
| 37 | } |