assertWikiIdParam( $wikiId ); Assert::parameter( $dbKey !== '', '$dbKey', 'must not be empty' ); // Replace spaces with underscores $dbKey = str_replace( ' ', '_', $dbKey ); $this->wikiId = $wikiId; $this->namespace = $namespace; $this->dbKey = $dbKey; } /** * Create PageReference for a local page. * * @param int $namespace * @param string $dbKey * @return PageReferenceValue */ public static function localReference( int $namespace, string $dbKey ): self { return new self( $namespace, $dbKey, self::LOCAL ); } /** * Get the ID of the wiki provided to the constructor. * * @return string|false */ public function getWikiId() { return $this->wikiId; } /** * @inheritDoc * * @return int */ public function getNamespace(): int { return $this->namespace; } /** * @inheritDoc * * @return string */ public function getDBkey(): string { return $this->dbKey; } /** * @inheritDoc */ public function isSamePageAs( PageReference $other ): bool { // NOTE: keep in sync with Title::isSamePageAs()! // NOTE: keep in sync with WikiPage::isSamePageAs()! return $this->getWikiId() === $other->getWikiId() && $this->getNamespace() === $other->getNamespace() && $this->getDBkey() === $other->getDBkey(); } /** * Returns a string representation of the title, for logging. This is purely informative * and must not be used programmatically. */ public function __toString(): string { $s = '[' . $this->namespace . ':' . $this->dbKey . ']'; if ( $this->wikiId ) { $s .= '@' . $this->wikiId; } return $s; } }