<?php

declare(strict_types=1);

namespace App\Framework\Discovery\Memory;

use App\Framework\Core\ValueObjects\Byte;
use App\Framework\Core\ValueObjects\Percentage;
use App\Framework\Discovery\ValueObjects\MemoryStrategy;

/**
 * Memory status information
 */
final readonly class MemoryStatusInfo
{
    public function __construct(
        public MemoryStatus   $status,
        public Byte           $currentUsage,
        public Byte           $peakUsage,
        public Byte           $memoryLimit,
        public Byte           $availableMemory,
        public Percentage     $memoryPressure,
        public MemoryStrategy $strategy
    ) {
    }

    public function toArray(): array
    {
        return [
            'status' => $this->status->value,
            'current_usage' => $this->currentUsage->toHumanReadable(),
            'peak_usage' => $this->peakUsage->toHumanReadable(),
            'memory_limit' => $this->memoryLimit->toHumanReadable(),
            'available_memory' => $this->availableMemory->toHumanReadable(),
            'memory_pressure' => $this->memoryPressure->toDecimal(),
            'strategy' => $this->strategy->value,
        ];
    }
}
