/** * @param AggregateRootIdentifier $identifier * @param int $expectedVersion * @param int $actualVersion */ public function __construct(AggregateRootIdentifier $identifier, $expectedVersion, $actualVersion) { $this->identifier = $identifier; $this->expectedVersion = (int) $expectedVersion; $this->actualVersion = (int) $actualVersion; parent::__construct(sprintf('Got an unexpected version [%d] instead of [%d] for aggregate [%s].', $this->actualVersion, $this->expectedVersion, $identifier->toString())); }
/** * @param UserIdentifier $identifier * * @return bool */ public function equals(AggregateRootIdentifier $identifier) { if (!$identifier instanceof $this) { return false; } return $this->toString() === $identifier->toString(); }
/** * @param Contract $aggregateType * @param AggregateRootIdentifier $aggregateRootIdentifier * * @return EventStream */ public function read(Contract $aggregateType, AggregateRootIdentifier $aggregateRootIdentifier) { $statement = $this->selectQuery->prepare(); $statement->bindValue(':aggregate_id', $aggregateRootIdentifier->toString()); $statement->bindValue(':aggregate_type', $aggregateType->toString()); $statement->execute(); $records = $statement->fetchAll(); $statement->closeCursor(); return new PdoReadRecordEventStream($aggregateRootIdentifier, $records, $this->eventSerializer); }
public function __construct(AggregateRootIdentifier $identifier) { parent::__construct(sprintf('Aggregate with identifier [%s] could not be found.', $identifier->toString())); }