<?php

namespace App\Framework\Cache\Strategies;

/**
 * Statistics for adaptive TTL optimization
 */
final class AdaptiveTtlStats
{
    private int $hits = 0;

    private int $misses = 0;

    public function recordHitMiss(bool $isHit): void
    {
        if ($isHit) {
            $this->hits++;
        } else {
            $this->misses++;
        }
    }

    public function getHitRate(): float
    {
        $total = $this->hits + $this->misses;

        return $total > 0 ? ($this->hits / $total) : 0.0;
    }

    public function getTotalRequests(): int
    {
        return $this->hits + $this->misses;
    }

    public function getHits(): int
    {
        return $this->hits;
    }

    public function getMisses(): int
    {
        return $this->misses;
    }
}
