Skip to content

Commit 10fe13b

Browse files
committed
more static methods
1 parent f8cea0f commit 10fe13b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Symfony/Component/HttpClient/CachingHttpClient.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
211211
// avoid throwing exception in ErrorChunk#__destruct()
212212
$chunk instanceof ErrorChunk && $chunk->didThrow(true);
213213
$context->passthru();
214-
$context->replaceResponse($this->createGatewayTimeoutResponse($method, $url, $options));
214+
$context->replaceResponse(self::createGatewayTimeoutResponse($method, $url, $options));
215215

216216
return;
217217
}
@@ -222,15 +222,15 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
222222
}
223223

224224
$headers = $context->getHeaders();
225-
$cacheControl = $this->parseCacheControlHeader($headers['cache-control'] ?? []);
225+
$cacheControl = self::parseCacheControlHeader($headers['cache-control'] ?? []);
226226

227227
if ($chunk->isFirst()) {
228228
$statusCode = $context->getStatusCode();
229229

230230
if (304 === $statusCode && null !== $freshness) {
231231
$maxAge = $this->determineMaxAge($headers, $cacheControl);
232232

233-
$cachedData['expires_at'] = $this->calculateExpiresAt($maxAge);
233+
$cachedData['expires_at'] = self::calculateExpiresAt($maxAge);
234234
$cachedData['stored_at'] = time();
235235
$cachedData['initial_age'] = (int) ($headers['age'][0] ?? 0);
236236
$cachedData['headers'] = array_merge($cachedData['headers'], array_diff_key($headers, self::EXCLUDED_HEADERS));
@@ -254,7 +254,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
254254

255255
if (Freshness::MustRevalidate === $freshness) {
256256
$context->passthru();
257-
$context->replaceResponse($this->createGatewayTimeoutResponse($method, $url, $options));
257+
$context->replaceResponse(self::createGatewayTimeoutResponse($method, $url, $options));
258258

259259
return;
260260
}
@@ -304,7 +304,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
304304
'headers' => array_diff_key($headers, self::EXCLUDED_HEADERS),
305305
'initial_age' => (int) ($headers['age'][0] ?? 0),
306306
'stored_at' => time(),
307-
'expires_at' => $this->calculateExpiresAt($maxAge),
307+
'expires_at' => self::calculateExpiresAt($maxAge),
308308
'chunks_count' => $chunkIndex,
309309
])
310310
->expiresAt($expiresAt)
@@ -457,7 +457,7 @@ private static function buildVariantKey(array $normalizedHeaders, array $varyFie
457457
*
458458
* @return array<string, string|true> the parsed Cache-Control directives
459459
*/
460-
private function parseCacheControlHeader(array $header): array
460+
private static function parseCacheControlHeader(array $header): array
461461
{
462462
$parsed = [];
463463
foreach ($header as $line) {
@@ -484,7 +484,7 @@ private function parseCacheControlHeader(array $header): array
484484
*/
485485
private function evaluateCacheFreshness(array $data): Freshness
486486
{
487-
$parseCacheControlHeader = $this->parseCacheControlHeader($data['headers']['cache-control'] ?? []);
487+
$parseCacheControlHeader = self::parseCacheControlHeader($data['headers']['cache-control'] ?? []);
488488

489489
if (isset($parseCacheControlHeader['no-cache'])) {
490490
return Freshness::Stale;
@@ -535,7 +535,7 @@ private function evaluateCacheFreshness(array $data): Freshness
535535
*/
536536
private function determineMaxAge(array $headers, array $cacheControl): ?int
537537
{
538-
$age = $this->getCurrentAge($headers);
538+
$age = self::getCurrentAge($headers);
539539

540540
if ($this->sharedCache && isset($cacheControl['s-maxage'])) {
541541
$sharedMaxAge = (int) $cacheControl['s-maxage'];
@@ -589,7 +589,7 @@ private function determineMaxAge(array $headers, array $cacheControl): ?int
589589
*
590590
* @return int The age of the response in seconds. Defaults to 0 if not present.
591591
*/
592-
private function getCurrentAge(array $headers): int
592+
private static function getCurrentAge(array $headers): int
593593
{
594594
return (int) ($headers['age'][0] ?? 0);
595595
}
@@ -601,7 +601,7 @@ private function getCurrentAge(array $headers): int
601601
*
602602
* @return int|null the expiration time of the response as a Unix timestamp, or null if the maximum age is null
603603
*/
604-
private function calculateExpiresAt(?int $maxAge): ?int
604+
private static function calculateExpiresAt(?int $maxAge): ?int
605605
{
606606
if (null === $maxAge) {
607607
return null;
@@ -700,7 +700,7 @@ private function createResponseFromCache(string $key, array $cachedData, string
700700
);
701701
}
702702

703-
private function createGatewayTimeoutResponse(string $method, string $url, array $options): MockResponse
703+
private static function createGatewayTimeoutResponse(string $method, string $url, array $options): MockResponse
704704
{
705705
return MockResponse::fromRequest(
706706
$method,

0 commit comments

Comments
 (0)