58 if ( $database !==
null && ( !is_string( $database ) || $database ===
'' ) ) {
59 throw new InvalidArgumentException(
'Database must be null or a non-empty string.' );
61 $this->database = $database;
62 if ( $schema !==
null && ( !is_string( $schema ) || $schema ===
'' ) ) {
63 throw new InvalidArgumentException(
'Schema must be null or a non-empty string.' );
64 } elseif ( $database ===
null && $schema !==
null ) {
65 throw new InvalidArgumentException(
'Schema must be null if database is null.' );
67 $this->schema = $schema;
68 if ( !is_string( $prefix ) ) {
69 throw new InvalidArgumentException(
"Prefix must be a string." );
71 $this->prefix = $prefix;
79 if ( $domain instanceof self ) {
83 if ( !is_string( $domain ) ) {
84 throw new InvalidArgumentException(
"Domain must be a string or " . __CLASS__ );
87 $parts = array_map( [ __CLASS__,
'decode' ], explode(
'-', $domain ) );
92 if ( count( $parts ) == 1 ) {
93 $database = $parts[0];
94 } elseif ( count( $parts ) == 2 ) {
95 list( $database, $prefix ) = $parts;
96 } elseif ( count( $parts ) == 3 ) {
97 list( $database, $schema, $prefix ) = $parts;
99 throw new InvalidArgumentException(
"Domain '$domain' has too few or too many parts." );
102 if ( $database ===
'' ) {
106 if ( $schema ===
'' ) {
110 $instance =
new self( $database, $schema, $prefix );
111 $instance->equivalentString = $domain;
154 if ( $this->isUnspecified() ) {
158 $other = self::newFromId( $other );
161 ( $this->database === $other->database || $this->database ===
null ) &&
162 ( $this->schema === $other->schema || $this->schema ===
null ) &&
163 $this->prefix === $other->prefix