Skip to content

Commit

Permalink
Update AzureBlobStorageAdapter.php, remove goto statement
Browse files Browse the repository at this point in the history
The goto statement can make the code's flow difficult to follow. PHP code is typically expected to have a more linear and understandable structure. For example, when using goto, it can jump from one part of the code to another in a non - sequential manner. This can lead to confusion for developers who are trying to understand the program's logic, especially in larger codebases.
  • Loading branch information
ywisax authored Dec 19, 2024
1 parent 704c10b commit f171c3c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/AzureBlobStorage/AzureBlobStorageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,20 @@ public function deleteDirectory(string $path): void
$options->setPrefix($resolved);

try {
start:
$listResults = $this->client->listBlobs($this->container, $options);
while (true) {
$listResults = $this->client->listBlobs($this->container, $options);

foreach ($listResults->getBlobs() as $blob) {
$this->client->deleteBlob($this->container, $blob->getName());
}
foreach ($listResults->getBlobs() as $blob) {
$this->client->deleteBlob($this->container, $blob->getName());
}

$continuationToken = $listResults->getContinuationToken();
$continuationToken = $listResults->getContinuationToken();

if ($continuationToken instanceof ContinuationToken) {
$options->setContinuationToken($continuationToken);
goto start;
if ($continuationToken instanceof ContinuationToken) {
$options->setContinuationToken($continuationToken);
continue;
}
break;
}
} catch (Throwable $exception) {
throw UnableToDeleteDirectory::atLocation($path, $exception->getMessage(), $exception);
Expand Down

0 comments on commit f171c3c

Please sign in to comment.