chore: complete update
This commit is contained in:
56
.archive/Archived/TemplateContent.php
Normal file
56
.archive/Archived/TemplateContent.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Archive\Archived;
|
||||
|
||||
final readonly class TemplateContent
|
||||
{
|
||||
public function __construct(
|
||||
public string $rawTemplate,
|
||||
public bool $hasUserSpecificContent = false,
|
||||
public bool $hasSessionData = false,
|
||||
public bool $hasFormElements = false,
|
||||
public bool $hasTimeBasedContent = false,
|
||||
public bool $hasRandomContent = false,
|
||||
public bool $hasCsrfTokens = false,
|
||||
public array $dynamicVariables = [],
|
||||
public array $staticBlocks = [],
|
||||
) {}
|
||||
|
||||
public function hasDynamicContent(): bool
|
||||
{
|
||||
return $this->hasUserSpecificContent
|
||||
|| $this->hasSessionData
|
||||
|| $this->hasFormElements
|
||||
|| $this->hasTimeBasedContent
|
||||
|| $this->hasRandomContent
|
||||
|| $this->hasCsrfTokens
|
||||
|| !empty($this->dynamicVariables);
|
||||
}
|
||||
|
||||
public function getDynamicContentTypes(): array
|
||||
{
|
||||
$types = [];
|
||||
|
||||
if ($this->hasUserSpecificContent) $types[] = 'user_specific';
|
||||
if ($this->hasSessionData) $types[] = 'session_data';
|
||||
if ($this->hasFormElements) $types[] = 'form_elements';
|
||||
if ($this->hasTimeBasedContent) $types[] = 'time_based';
|
||||
if ($this->hasRandomContent) $types[] = 'random_content';
|
||||
if ($this->hasCsrfTokens) $types[] = 'csrf_tokens';
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
public function getCharacteristics(): array
|
||||
{
|
||||
return [
|
||||
'has_dynamic_content' => $this->hasDynamicContent(),
|
||||
'dynamic_types' => $this->getDynamicContentTypes(),
|
||||
'dynamic_variables_count' => count($this->dynamicVariables),
|
||||
'static_blocks_count' => count($this->staticBlocks),
|
||||
'template_size' => strlen($this->rawTemplate),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user