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,46 @@
<?php
namespace App\Framework\Cache\Compression;
use App\Framework\Cache\CompressionAlgorithm;
final class GzipCompression implements CompressionAlgorithm
{
private const string PREFIX = 'gz:';
private int $level;
private int $threshold;
public function __construct(int $compressionLevel = -1, int $minLengthToCompress = 1024)
{
$this->level = $compressionLevel;
$this->threshold = $minLengthToCompress;
}
public function compress(string $value, bool $forceCompression = false): string
{
if (!$forceCompression && strlen($value) < $this->threshold) {
return $value;
}
$compressed = gzcompress($value, $this->level);
if ($compressed === false) {
// Fallback auf Originalwert bei Fehler
return $value;
}
return self::PREFIX . $compressed;
}
public function decompress(string $value): string
{
if (!$this->isCompressed($value)) {
return $value;
}
$raw = substr($value, strlen(self::PREFIX));
$decompressed = @gzuncompress($raw);
return $decompressed !== false ? $decompressed : $value;
}
public function isCompressed(string $value): bool
{
return strncmp($value, self::PREFIX, strlen(self::PREFIX)) === 0;
}
}