Skip to content

Commit 38b1184

Browse files
BEG-81: Remove unnecessary condition and move setting of header to constructor
1 parent 7dc5a9b commit 38b1184

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Model/Api/PrerenderClient.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ public function __construct(
3434
LoggerInterface $logger
3535
) {
3636
$this->prerenderConfigHelper = $prerenderConfigHelper;
37-
$this->client = $client;
3837
$this->jsonSerializer = $jsonSerializer;
3938
$this->logger = $logger;
39+
$this->client = $client;
40+
$this->client->addHeader('content-type', 'application/json');
4041
}
4142

4243
public function recacheUrls(array $urls, int $storeId): void
@@ -50,13 +51,9 @@ public function recacheUrls(array $urls, int $storeId): void
5051
return;
5152
}
5253

53-
if (count($urls) > self::MAX_URLS) {
54-
$batches = array_chunk($urls, self::MAX_URLS);
55-
foreach ($batches as $batch) {
56-
$this->sendRequest($batch, $token);
57-
}
58-
} else {
59-
$this->sendRequest($urls, $token);
54+
$batches = array_chunk($urls, self::MAX_URLS);
55+
foreach ($batches as $batch) {
56+
$this->sendRequest($batch, $token);
6057
}
6158
}
6259

@@ -68,7 +65,6 @@ private function sendRequest(array $urls, string $token): void
6865
'urls' => $urls
6966
]
7067
);
71-
$this->client->addHeader('content-type', 'application/json');
7268
try {
7369
$this->client->post(self::PRERENDER_RECACHE_URL, $payload);
7470
} catch (\Exception $e) {

0 commit comments

Comments
 (0)