Skip to content

Commit ac577bc

Browse files
committed
early return if fetched
1 parent 1675f78 commit ac577bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/WpOrg/Api/Client.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composer\Downloader\TransportException;
88
use Composer\Util\HttpDownloader;
99
use Composer\Util\Loop;
10+
use Composer\Util\SyncHelper;
1011
use React\Promise\PromiseInterface;
1112

1213
use function React\Promise\resolve;
@@ -22,6 +23,15 @@ public function __construct(
2223

2324
public function isClosed(string $slug): bool
2425
{
26+
$slug = trim($slug);
27+
if ($slug === '') {
28+
return false;
29+
}
30+
31+
if (array_key_exists($slug, $this->isClosed)) {
32+
return $this->isClosed[$slug];
33+
}
34+
2535
$promise = $this->fetchIsClosedAsync($slug)
2636
->then(fn (bool $isClosed) => $this->isClosed[$slug] = $isClosed);
2737

0 commit comments

Comments
 (0)