Page MenuHomePhabricator
Paste P54705

Alternative StatementGuid constructor
ActivePublic

Authored by Ollie.Shotton_WMDE on Jan 12 2024, 12:13 PM.
Tags
None
Referenced Files
F41667600: Alternative StatementGuid constructor
Jan 12 2024, 12:13 PM
Subscribers
None
public function __construct( EntityId $entityId, string $guidPart, string $originalStatementId = null ) {
$constructedStatementId = $entityId->getSerialization() . self::SEPARATOR . $guidPart;
if ( $originalStatementId !== null
&& strtolower( $originalStatementId ) !== strtolower( $constructedStatementId ) ) {
throw new InvalidArgumentException( '$originalStatementId does not match $entityId and/or $guidPart' );
}
// use the original serialization when available to avoid normalizing the entity id prefix
$this->serialization = $originalStatementId ?? $constructedStatementId;
$this->entityId = $entityId;
$this->guidPart = $guidPart;
}