<?php

declare(strict_types=1);

namespace App\Framework\Process\Services;

use App\Framework\Process\ValueObjects\SystemInfo\CpuInfo;
use App\Framework\Process\ValueObjects\SystemInfo\DiskInfo;
use App\Framework\Process\ValueObjects\SystemInfo\LoadAverage;
use App\Framework\Process\ValueObjects\SystemInfo\MemoryInfo;
use App\Framework\Process\ValueObjects\SystemInfo\ProcessInfo;
use App\Framework\Process\ValueObjects\SystemInfo\SystemUptime;

/**
 * Aggregierte System-Informationen.
 */
final readonly class SystemInfo
{
    public function __construct(
        public SystemUptime $uptime,
        public LoadAverage $load,
        public MemoryInfo $memory,
        public DiskInfo $disk,
        public CpuInfo $cpu,
        public ProcessInfo $processes
    ) {
    }

    /**
     * Konvertiert zu Array für API/JSON Ausgabe.
     *
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'uptime' => $this->uptime->toArray(),
            'load' => $this->load->toArray(),
            'memory' => $this->memory->toArray(),
            'disk' => $this->disk->toArray(),
            'cpu' => $this->cpu->toArray(),
            'processes' => $this->processes->toArray(),
        ];
    }
}
