public function setUserNameMatchFilter( $names, $allow ) {

		if ( !is_array( $names ) ) {
			throw new UnexpectedValueException( __METHOD__ . ' expects an array as parameter.' );
		}

		$allow = (bool)$allow;

		Hooks::register(
			static::HOOKNAME,
			function ( &$username ) use ( $names, $allow ) {
				if ( isset( $names[ $username ] ) ) {
					return $allow;
				}
				foreach ( $names as $pattern ) {
					# If $pattern is no regex, create one from it.
					if ( @preg_match( $pattern, null ) === false ) {
						$pattern = str_replace( '\\', '\\\\', $pattern );
						$pattern = str_replace( '/', '\\/', $pattern );
						$pattern = "/$pattern/";
					}
					if ( preg_match( $pattern, $username ) ) {
						return $allow;
					}
				}
				return !$allow;
			}
		);

	}