public function checkTargetPath(string $targetPath): void
    {
        if ($this->fileSystem->has($targetPath)) {
            if (! $this->config->hasOverwrite()) {
                throw new FileExistsException(sprintf('The target file "%s" already exists', $targetPath));
            }
            if ($this->config->hasBackup()) {
                $backupTarget = $targetPath . '.bak';
                if ($this->fileSystem->has($backupTarget)) {
                    throw new FileExistsException(sprintf(
                        'The backup target file "%s" already exists',
                        $backupTarget
                    ));
                }
                $this->fileSystem->copy($targetPath, $backupTarget);
            }
            $this->fileSystem->delete($targetPath);
        }
    }