<?php

declare(strict_types=1);

namespace App\Framework\Metrics;

/**
 * Mutable service for collecting framework-internal counters
 * Wraps immutable FrameworkCounters for DI compatibility
 */
final class FrameworkMetricsCollector
{
    private FrameworkCounters $counters;

    public function __construct()
    {
        $this->counters = new FrameworkCounters();
    }

    public function increment(string $name, int $by = 1): void
    {
        $this->counters = $this->counters->increment($name, $by);
    }

    public function reset(string $name): void
    {
        $this->counters = $this->counters->reset($name);
    }

    public function resetAll(): void
    {
        $this->counters = $this->counters->resetAll();
    }

    public function get(string $name): Counter
    {
        return $this->counters->get($name);
    }

    public function snapshot(): FrameworkCounters
    {
        return $this->counters;
    }

    /**
     * Export framework counters as MetricsCollection
     */
    public function collect(): MetricsCollection
    {
        return $this->counters->toMetricsCollection();
    }
}
