MediaWiki master
LinkTarget.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
23use Stringable;
24use Wikimedia\Parsoid\Core\LinkTarget as ParsoidLinkTarget;
25
33interface LinkTarget extends Stringable, ParsoidLinkTarget {
34
41 public function getNamespace(): int;
42
50 public function inNamespace( int $ns ): bool;
51
58 public function getFragment(): string;
59
66 public function hasFragment(): bool;
67
78 public function getDBkey(): string;
79
94 public function getText(): string;
95
106 public function createFragmentTarget( string $fragment );
107
114 public function isExternal(): bool;
115
122 public function getInterwiki(): string;
123
134 public function isSameLinkAs( ParsoidLinkTarget $other ): bool;
135
142 public function __toString(): string;
143
144}
Represents the target of a wiki link.
inNamespace(int $ns)
Convenience function to check if the target is in a given namespace.
getInterwiki()
The interwiki component of this LinkTarget.
hasFragment()
Whether the link target has a fragment.
__toString()
Return an informative human-readable representation of the link target, for use in logging and debugg...
getFragment()
Get the link fragment in text form (i.e.
getNamespace()
Get the namespace index.
getDBkey()
Get the main part of the link target, in canonical database form.
isSameLinkAs(ParsoidLinkTarget $other)
Check whether the given LinkTarget refers to the same target as this LinkTarget.
isExternal()
Whether this LinkTarget has an interwiki component.
getText()
Get the main part of the link target, in text form.
createFragmentTarget(string $fragment)
Create a new LinkTarget with a different fragment on the same page.