namespaceId = null; } else { $this->namespaceId = intval( $namespaceId ); } $this->namespaceName = str_replace( ' ', '_', $namespaceName ); $this->pageName = str_replace( ' ', '_', $pageName ); } /** * Do we know the namespace ID of the page on the foreign wiki? * @return bool */ public function isNamespaceIdKnown() { return !is_null( $this->namespaceId ); } /** * @return int * @throws MWException If isNamespaceIdKnown() is false, it does not make * sense to call this function. */ public function getNamespaceId() { if ( is_null( $this->namespaceId ) ) { throw new MWException( "Attempted to call getNamespaceId when the namespace ID is not known" ); } return $this->namespaceId; } /** @return string */ public function getNamespaceName() { return $this->namespaceName; } /** @return string */ public function getText() { return $this->pageName; } /** @return string */ public function getFullText() { $result = ''; if ( $this->namespaceName ) { $result .= $this->namespaceName . ':'; } $result .= $this->pageName; return $result; } /** * Returns a string representation of the title, for logging. This is purely * informative and must not be used programmatically. Use the appropriate * ImportTitleFactory to generate the correct string representation for a * given use. * * @return string */ public function __toString() { $name = ''; if ( $this->isNamespaceIdKnown() ) { $name .= '{ns' . $this->namespaceId . '}'; } else { $name .= '{ns??}'; } $name .= $this->namespaceName . ':' . $this->pageName; return $name; } }