<?php

declare(strict_types=1);

namespace App\Framework\Database\Cache\ValueObjects;

/**
 * Comprehensive cache metrics snapshot
 */
final readonly class CacheMetricsSnapshot
{
    public function __construct(
        public CacheOverviewMetrics $overview,
        public CachePerformanceMetrics $performance,
        public array $entities,
        public QueryMetrics $queries,
        public array $regions,
        public array $recommendations
    ) {
    }

    public function toArray(): array
    {
        return [
            'overview' => $this->overview->toArray(),
            'performance' => $this->performance->toArray(),
            'entities' => array_map(fn ($metric) => $metric->toArray(), $this->entities),
            'queries' => $this->queries->toArray(),
            'regions' => array_map(fn ($metric) => $metric->toArray(), $this->regions),
            'recommendations' => array_map(fn ($rec) => $rec->toArray(), $this->recommendations),
        ];
    }
}
