45 if ( $database !==
null && ( !is_string( $database ) || $database ===
'' ) ) {
46 throw new InvalidArgumentException(
'Database must be null or a non-empty string.' );
48 $this->database = $database;
49 if ( $schema !==
null && ( !is_string( $schema ) || $schema ===
'' ) ) {
50 throw new InvalidArgumentException(
'Schema must be null or a non-empty string.' );
51 } elseif ( $database ===
null && $schema !==
null ) {
52 throw new InvalidArgumentException(
'Schema must be null if database is null.' );
54 $this->schema = $schema;
55 if ( !is_string( $prefix ) ) {
56 throw new InvalidArgumentException(
"Prefix must be a string." );
58 $this->prefix = $prefix;
66 if ( $domain instanceof self ) {
70 $parts = explode(
'-', $domain );
71 foreach ( $parts as &$part ) {
72 $part = strtr( $part, [
'?h' =>
'-',
'??' =>
'?' ] );
78 if ( count( $parts ) == 1 ) {
79 $database = $parts[0];
80 } elseif ( count( $parts ) == 2 ) {
81 [ $database, $prefix ] = $parts;
82 } elseif ( count( $parts ) == 3 ) {
83 [ $database, $schema, $prefix ] = $parts;
85 throw new InvalidArgumentException(
"Domain '$domain' has too few or too many parts." );
88 if ( $database ===
'' ) {
92 if ( $schema ===
'' ) {
96 $instance =
new self( $database, $schema, $prefix );
140 if ( $this->isUnspecified() ) {
144 $other = self::newFromId( $other );
147 ( $this->database === $other->database || $this->database ===
null ) &&
148 ( $this->schema === $other->schema || $this->schema ===
null ) &&
149 $this->prefix === $other->prefix