<?php

declare(strict_types=1);

namespace App\Framework\Metrics;

/**
 * Immutable counter value object
 * Represents a single named counter with its current value
 */
final readonly class Counter
{
    public function __construct(
        public string $name,
        public int $value = 0
    ) {
    }

    public function increment(int $by = 1): self
    {
        return new self($this->name, $this->value + $by);
    }

    public function reset(): self
    {
        return new self($this->name, 0);
    }

    public function withValue(int $value): self
    {
        return new self($this->name, $value);
    }
}
