Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
7 / 7
OAuthUrlFactory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
7 / 7
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 getOAuthUrl
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
<?php
namespace MediaWiki\Extension\WikibaseManifest;
use ExtensionRegistry;
use MediaWiki\SpecialPage\SpecialPageFactory;
class OAuthUrlFactory {
    private const OAUTH_EXT_NAME = 'OAuth';
    private const OAUTH_PAGE_NAME = 'OAuthConsumerRegistration';
    private $registry;
    private $specialPageFactory;
    public function __construct(
        ExtensionRegistry $registry,
        SpecialPageFactory $specialPageFactory
    ) {
        $this->registry = $registry;
        $this->specialPageFactory = $specialPageFactory;
    }
    public function getOAuthUrl(): OAuthUrl {
        if ( $this->registry->isLoaded( self::OAUTH_EXT_NAME ) ) {
            $specialPage = $this->specialPageFactory->getPage( self::OAUTH_PAGE_NAME );
            return new SpecialPageOAuthUrl( $specialPage );
        }
        return new NullOAuthUrl();
    }
}