private function createItemPosition(Collection $collection, ?int $newPosition): int
    {
        if (!$this->isCollectionDynamic($collection)) {
            return $this->positionHelper->createPosition(
                $this->getPositionHelperItemConditions(
                    $collection->id,
                    $collection->status
                ),
                $newPosition
            );
        }

        if ($newPosition === null) {
            throw new BadStateException('collection', 'When adding items to dynamic collections, position is mandatory.');
        }

        return $this->incrementItemPositions($collection, $newPosition);
    }