/** * {@inheritdoc} */ public function compareTo($object) { if ($this === $object) { return 0; } assert(Test::areSameType($this, $object), sprintf('Comparison requires instance of %s', static::class)); assert(Test::areEqual($this->aggregateType, $object->aggregateType), 'Comparison must be for a single aggregate type'); assert(Test::areEqual($this->aggregateId, $object->aggregateId), 'Comparison must be for a single aggregate identifier'); $thisSeq = $this->sequence; $thatSeq = $object->sequence; if ($thisSeq > $thatSeq) { return 1; } if ($thisSeq < $thatSeq) { return -1; } return 0; }