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,14 @@
<?php
declare(strict_types=1);
namespace App\Framework\Analytics\Storage;
interface AnalyticsStorageInterface
{
public function store(array $eventData): void;
public function query(array $filters = []): array;
public function aggregate(string $metric, array $filters = []): array;
}

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Framework\Analytics\Storage;
final class FileAnalyticsStorage implements AnalyticsStorageInterface
{
public function __construct(
private readonly string $storagePath
) {
if (!is_dir($this->storagePath)) {
mkdir($this->storagePath, 0755, true);
}
}
public function store(array $eventData): void
{
$date = date('Y-m-d');
$filename = $this->storagePath . "/analytics-{$date}.jsonl";
$line = json_encode($eventData) . "\n";
file_put_contents($filename, $line, FILE_APPEND | LOCK_EX);
}
public function query(array $filters = []): array
{
// Einfache Implementation - kann erweitert werden
$files = glob($this->storagePath . '/analytics-*.jsonl');
$events = [];
foreach ($files as $file) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
foreach ($lines as $line) {
$event = json_decode($line, true);
if ($this->matchesFilters($event, $filters)) {
$events[] = $event;
}
}
}
return $events;
}
public function aggregate(string $metric, array $filters = []): array
{
$events = $this->query($filters);
// Einfache Aggregation - kann erweitert werden
$aggregated = [];
foreach ($events as $event) {
$key = $event['type'] ?? 'unknown';
$aggregated[$key] = ($aggregated[$key] ?? 0) + 1;
}
return $aggregated;
}
private function matchesFilters(array $event, array $filters): bool
{
foreach ($filters as $key => $value) {
if (!isset($event[$key]) || $event[$key] !== $value) {
return false;
}
}
return true;
}
}