57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?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),
|
|
];
|
|
}
|
|
}
|