24use Wikimedia\Assert\Assert;
78 public function __construct( $namespace, $dbkey, $fragment =
'', $interwiki =
'' ) {
79 Assert::parameterType(
'integer',
$namespace,
'$namespace' );
80 Assert::parameterType(
'string',
$dbkey,
'$dbkey' );
81 Assert::parameterType(
'string',
$fragment,
'$fragment' );
82 Assert::parameterType(
'string',
$interwiki,
'$interwiki' );
85 Assert::parameter( !preg_match(
'/^_|[ \r\n\t]|_$/',
$dbkey ),
'$dbkey',
86 "invalid DB key '$dbkey'" );
87 Assert::parameter(
$dbkey !==
'',
'$dbkey',
'should not be empty' );
100 return $this->namespace;
109 return $this->
namespace == $ns;
117 return $this->fragment;
125 return $this->fragment !==
'';
152 return str_replace(
'_',
' ', $this->
getDBkey() );
179 return $this->interwiki !==
'';
189 return $this->interwiki;
201 $name = $this->
namespace . ':' . $this->dbkey;
203 if ( $this->fragment !== '' ) {
204 $name .=
'#' . $this->fragment;
207 if ( $this->interwiki !==
'' ) {
208 $name = $this->interwiki .
':' .
$name;
Represents a page (or page fragment) title within MediaWiki.
isExternal()
Whether it has an interwiki part.
__construct( $namespace, $dbkey, $fragment='', $interwiki='')
Constructs a TitleValue.
getInterwiki()
Returns the interwiki part.
getText()
Returns the title in text form, without namespace prefix or fragment.
createFragmentTarget( $fragment)
Creates a new TitleValue for a different fragment of the same page.
getDBkey()
Returns the title's DB key, as supplied to the constructor, without namespace prefix or fragment.
__toString()
Returns a string representation of the title, for logging.
Allows to change the fields on the form that will be generated $name