chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
namespace Archive\Archived;
final readonly class CacheCapability
{
public function __construct(
public bool $canBeCachedFully,
public bool $canBeCachedPartially,
public bool $supportsFragments,
public CacheComplexity $complexity,
public array $restrictions = [],
) {}
public static function fromTemplateContent(TemplateContent $content): self
{
$canBeCachedFully = !$content->hasDynamicContent();
$canBeCachedPartially = !$content->hasUserSpecificContent
&& !$content->hasSessionData
&& !$content->hasTimeBasedContent;
$supportsFragments = count($content->staticBlocks) > 0;
$complexity = match (true) {
!$content->hasDynamicContent() => CacheComplexity::LOW,
$content->hasUserSpecificContent || $content->hasSessionData => CacheComplexity::HIGH,
$content->hasFormElements || $content->hasTimeBasedContent => CacheComplexity::MEDIUM,
default => CacheComplexity::EXTREME,
};
$restrictions = [];
if ($content->hasUserSpecificContent) $restrictions[] = 'user_specific';
if ($content->hasSessionData) $restrictions[] = 'session_dependent';
if ($content->hasTimeBasedContent) $restrictions[] = 'time_sensitive';
if ($content->hasCsrfTokens) $restrictions[] = 'csrf_protected';
return new self(
canBeCachedFully: $canBeCachedFully,
canBeCachedPartially: $canBeCachedPartially,
supportsFragments: $supportsFragments,
complexity: $complexity,
restrictions: $restrictions,
);
}
public function isFullyCacheable(): bool
{
return $this->canBeCachedFully;
}
public function isPartiallyCacheable(): bool
{
return $this->canBeCachedPartially;
}
public function getComplexity(): CacheComplexity
{
return $this->complexity;
}
public function hasRestriction(string $restriction): bool
{
return in_array($restriction, $this->restrictions, true);
}
}