summaryrefslogtreecommitdiff
path: root/includes/title/TitleValue.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /includes/title/TitleValue.php
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'includes/title/TitleValue.php')
-rw-r--r--includes/title/TitleValue.php24
1 files changed, 6 insertions, 18 deletions
diff --git a/includes/title/TitleValue.php b/includes/title/TitleValue.php
index 5cac3470..a0f3b6f9 100644
--- a/includes/title/TitleValue.php
+++ b/includes/title/TitleValue.php
@@ -21,6 +21,7 @@
* @license GPL 2+
* @author Daniel Kinzler
*/
+use Wikimedia\Assert\Assert;
/**
* Represents a page (or page fragment) title within %MediaWiki.
@@ -67,26 +68,13 @@ class TitleValue {
* @throws InvalidArgumentException
*/
public function __construct( $namespace, $dbkey, $fragment = '' ) {
- if ( !is_int( $namespace ) ) {
- throw new InvalidArgumentException( '$namespace must be an integer' );
- }
-
- if ( !is_string( $dbkey ) ) {
- throw new InvalidArgumentException( '$dbkey must be a string' );
- }
+ Assert::parameterType( 'integer', $namespace, '$namespace' );
+ Assert::parameterType( 'string', $dbkey, '$dbkey' );
+ Assert::parameterType( 'string', $fragment, '$fragment' );
// Sanity check, no full validation or normalization applied here!
- if ( preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ) ) {
- throw new InvalidArgumentException( '$dbkey must be a valid DB key: ' . $dbkey );
- }
-
- if ( !is_string( $fragment ) ) {
- throw new InvalidArgumentException( '$fragment must be a string' );
- }
-
- if ( $dbkey === '' ) {
- throw new InvalidArgumentException( '$dbkey must not be empty' );
- }
+ Assert::parameter( !preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ), '$dbkey', 'invalid DB key' );
+ Assert::parameter( $dbkey !== '', '$dbkey', 'should not be empty' );
$this->namespace = $namespace;
$this->dbkey = $dbkey;