public function getLastSequenceNumber()
    {
        if (count($this->events) === 0) {
            return $this->lastCommittedSequenceNumber;
        }
        if ($this->lastSequenceNumber === null) {
            $event = end($this->events);
            $this->lastSequenceNumber = $event->getSequenceNumber();
        }
        return $this->lastSequenceNumber;
    }