23use InvalidArgumentException;
46 throw new InvalidArgumentException(
'Database must be null or a non-empty string.' );
50 throw new InvalidArgumentException(
'Schema must be null or a non-empty string.' );
52 throw new InvalidArgumentException(
'Schema must be null if database is null.' );
56 throw new InvalidArgumentException(
"Prefix must be a string." );
66 if ( $domain instanceof
self ) {
70 $parts =
array_map( [ __CLASS__,
'decode' ], explode(
'-', $domain ) );
75 if ( count( $parts ) == 1 ) {
77 }
elseif ( count( $parts ) == 2 ) {
79 }
elseif ( count( $parts ) == 3 ) {
82 throw new InvalidArgumentException(
"Domain '$domain' has too few or too many parts." );
100 return new self(
null,
null,
'' );
108 if ( $other instanceof
self ) {
110 $this->database === $other->database &&
111 $this->schema === $other->schema &&
112 $this->prefix === $other->prefix
116 return ( $this->
getId() === $other );
141 ( $this->database === $other->database || $this->database ===
null ) &&
142 ( $this->schema === $other->schema || $this->schema ===
null ) &&
143 $this->prefix === $other->prefix
153 $this->database ===
null && $this->schema ===
null && $this->prefix ===
''
182 if ( $this->equivalentString ===
null ) {
193 $parts = [ (
string)$this->database ];
194 if ( $this->schema !==
null ) {
197 if ( $this->prefix !=
'' || $this->schema !==
null ) {
206 return implode(
'-',
array_map( [ __CLASS__,
'encode' ], $parts ) );
209 private static function encode( $decoded ) {
212 $length =
strlen( $decoded );
213 for ( $i = 0; $i < $length; ++
$i ) {
214 $char = $decoded[
$i];
215 if ( $char ===
'-' ) {
217 }
elseif ( $char ===
'?' ) {
227 private static function decode( $encoded ) {
230 $length =
strlen( $encoded );
231 for ( $i = 0; $i < $length; ++
$i ) {
232 $char = $encoded[
$i];
233 if ( $char ===
'?' ) {
234 $nextChar = $encoded[$i + 1] ??
null;
235 if ( $nextChar ===
'h' ) {
238 }
elseif ( $nextChar ===
'?' ) {
256 return $this->
getId();
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Class to handle database/prefix specification for IDatabase domains.
string $equivalentString
Cache of convertToString()
isCompatible( $other)
Check whether the domain $other meets the specifications of this domain.
static newFromId( $domain)
__construct( $database, $schema, $prefix)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string