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." );
54 throw new InvalidArgumentException(
"Prefix must be a string." );
64 if ( $domain instanceof
self ) {
68 $parts = array_map( [ __CLASS__,
'decode' ], explode(
'-', $domain ) );
73 if ( count( $parts ) == 1 ) {
75 } elseif ( count( $parts ) == 2 ) {
77 } elseif ( count( $parts ) == 3 ) {
80 throw new InvalidArgumentException(
"Domain has too few or too many parts." );
94 return new self(
null,
null,
'' );
104 $this->database === $other->database &&
105 $this->schema === $other->schema &&
106 $this->prefix === $other->prefix
110 return ( $this->
getId() === $other );
138 if ( $this->equivalentString ===
null ) {
150 if ( $this->schema !==
null ) {
153 if ( $this->prefix !=
'' ) {
157 return implode(
'-', array_map( [ __CLASS__,
'encode' ], $parts ) );
160 private static function encode( $decoded ) {
163 $length = strlen( $decoded );
164 for ( $i = 0; $i < $length; ++$i ) {
165 $char = $decoded[$i];
166 if ( $char ===
'-' ) {
168 } elseif ( $char ===
'?' ) {
178 private static function decode( $encoded ) {
181 $length = strlen( $encoded );
182 for ( $i = 0; $i < $length; ++$i ) {
183 $char = $encoded[$i];
184 if ( $char ===
'?' ) {
185 $nextChar = isset( $encoded[$i + 1] ) ? $encoded[$i + 1] :
null;
186 if ( $nextChar ===
'h' ) {
189 } elseif ( $nextChar ===
'?' ) {
207 return $this->
getId();
Class to handle database/prefix specification for IDatabase domains.
string $equivalentString
Cache of convertToString()
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