24use Wikimedia\Assert\Assert;
25use Wikimedia\Assert\ParameterAssertionException;
26use Wikimedia\Assert\ParameterTypeException;
95 throw new ParameterTypeException(
'$namespace',
'int' );
100 }
catch ( ParameterAssertionException $ex ) {
128 $this->dbkey = strtr(
$title,
' ',
'_' );
148 throw new ParameterTypeException(
'$namespace',
'int' );
150 if ( !is_string(
$title ) ) {
151 throw new ParameterTypeException(
'$title',
'string' );
154 throw new ParameterTypeException(
'$fragment',
'string' );
157 throw new ParameterTypeException(
'$interwiki',
'string' );
160 Assert::parameter( !preg_match(
'/^[_ ]|[\r\n\t]|[_ ]$/',
$title ),
'$title',
161 "invalid name '$title'" );
171 'should not be empty unless namespace is main'
189 return $this->
namespace == $ns;
205 return $this->fragment !==
'';
232 return str_replace(
'_',
' ', $this->dbkey );
259 return $this->interwiki !==
'';
281 $name = $this->
namespace . ':' . $this->dbkey;
283 if ( $this->fragment !== '' ) {
284 $name .=
'#' . $this->fragment;
287 if ( $this->interwiki !==
'' ) {
288 $name = $this->interwiki .
':' . $name;
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Represents a page (or page fragment) title within MediaWiki.
isExternal()
Whether it has an interwiki part.
__construct( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue.
getInterwiki()
Returns the interwiki part.
static assertValidSpec( $namespace, $title, $fragment='', $interwiki='')
Asserts that the given parameters could be used to construct a TitleValue object.
string $prefixedText
Text form including namespace/interwiki, initialised on demand.
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.
static tryNew( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue, or returns null if the parameters are not valid.
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.