private function getCommitOrder(): array
    {
        static $calculator = null;
        if (null === $calculator) {
            $calculator = new CommitOrderCalculator();
        }

        $objects = array_merge($this->documentInsertions, $this->documentUpdates, $this->documentDeletions);

        $classes = [];
        foreach ($objects as $object) {
            $metadata = $this->manager->getClassMetadata(get_class($object));

            $calculator->addClass($metadata);
            $classes[$metadata->getName()] = $metadata;
        }

        $order = $calculator->getOrder(array_keys($classes));

        return array_map(function (array $element) {
            return $element[0]->getClassName();
        }, $order);
    }