*/
class MediaWikiPageNameNormalizer {
+ /**
+ * @var Http
+ */
+ private $http;
+
+ /**
+ * @param Http|null $http
+ */
+ public function __construct( Http $http = null ) {
+ if ( !$http ) {
+ $http = new Http();
+ }
+
+ $this->http = $http;
+ }
+
/**
* Returns the normalized form of the given page title, using the
* normalization rules of the given site. If the given title is a redirect,
* @throws \MWException
*/
public function normalizePageName( $pageName, $apiUrl ) {
-
// Check if we have strings as arguments.
if ( !is_string( $pageName ) ) {
throw new \MWException( '$pageName must be a string' );
// Go on call the external site
// @todo we need a good way to specify a timeout here.
- $ret = Http::get( $url, [], __METHOD__ );
+ $ret = $this->http->get( $url, [], __METHOD__ );
if ( $ret === false ) {
wfDebugLog( "MediaWikiSite", "call to external site failed: $url" );