Go to the documentation of this file.
24 use Wikimedia\Assert\Assert;
25 use Wikimedia\Assert\ParameterTypeException;
90 throw new ParameterTypeException(
'$namespace',
'int' );
92 if ( !is_string(
$title ) ) {
93 throw new ParameterTypeException(
'$title',
'string' );
96 throw new ParameterTypeException(
'$fragment',
'string' );
99 throw new ParameterTypeException(
'$interwiki',
'string' );
103 Assert::parameter( !preg_match(
'/^[_ ]|[\r\n\t]|[_ ]$/',
$title ),
'$title',
104 "invalid name '$title'" );
109 'should not be empty unless namespace is main and fragment or interwiki is non-empty'
113 $this->dbkey = strtr(
$title,
' ',
'_' );
132 return $this->
namespace == $ns;
148 return $this->fragment !==
'';
175 return str_replace(
'_',
' ', $this->dbkey );
202 return $this->interwiki !==
'';
224 $name = $this->
namespace . ':' . $this->dbkey;
226 if ( $this->fragment !== '' ) {
230 if ( $this->interwiki !==
'' ) {
231 $name = $this->interwiki .
':' . $name;
string $prefixedText
Text form including namespace/interwiki, initialised on demand.
isExternal()
Whether it has an interwiki part.
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.
getText()
Returns the title in text form, without namespace prefix or fragment.
getInterwiki()
Returns the interwiki part.
__construct( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue.
Represents a page (or page fragment) title within MediaWiki.