59 if ( $database !==
null && ( !is_string( $database ) || $database ===
'' ) ) {
60 throw new InvalidArgumentException(
'Database must be null or a non-empty string.' );
62 $this->database = $database;
63 if ( $schema !==
null && ( !is_string( $schema ) || $schema ===
'' ) ) {
64 throw new InvalidArgumentException(
'Schema must be null or a non-empty string.' );
65 } elseif ( $database ===
null && $schema !==
null ) {
66 throw new InvalidArgumentException(
'Schema must be null if database is null.' );
68 $this->schema = $schema;
69 if ( !is_string( $prefix ) ) {
70 throw new InvalidArgumentException(
"Prefix must be a string." );
72 $this->prefix = $prefix;
80 if ( $domain instanceof self ) {
84 if ( !is_string( $domain ) ) {
85 throw new InvalidArgumentException(
"Domain must be a string or " . __CLASS__ );
88 $parts = explode(
'-', $domain );
89 foreach ( $parts as &$part ) {
90 $part = strtr( $part, [
'?h' =>
'-',
'??' =>
'?' ] );
96 if ( count( $parts ) == 1 ) {
97 $database = $parts[0];
98 } elseif ( count( $parts ) == 2 ) {
99 [ $database, $prefix ] = $parts;
100 } elseif ( count( $parts ) == 3 ) {
101 [ $database, $schema, $prefix ] = $parts;
103 throw new InvalidArgumentException(
"Domain '$domain' has too few or too many parts." );
106 if ( $database ===
'' ) {
110 if ( $schema ===
'' ) {
114 $instance =
new self( $database, $schema, $prefix );
115 $instance->equivalentString = $domain;
158 if ( $this->isUnspecified() ) {
162 $other = self::newFromId( $other );
165 ( $this->database === $other->database || $this->database ===
null ) &&
166 ( $this->schema === $other->schema || $this->schema ===
null ) &&
167 $this->prefix === $other->prefix