<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Developer;

use PpPhp\Core\Platform\Bootstrap\PlatformBootstrap;
use PpPhp\Core\Platform\Kernel\Platform;

final class PlatformMetrics
{
    public function snapshot(): array
    {
        $loader = PlatformBootstrap::loader();

        return [
            'timestamp' => date('c'),
            'phpVersion' => PHP_VERSION,
            'memoryUsage' => memory_get_usage(true),
            'memoryPeak' => memory_get_peak_usage(true),
            'classes' => $loader ? $loader->count() : 0,
            'manifests' => count(Platform::manifests()->all()),
            'modules' => Platform::modules()->count(),
            'plugins' => Platform::plugins()->count(),
            'packages' => Platform::packages()->count(),
            'themes' => Platform::themes()->count(),
            'services' => count(Platform::registries()->services->all()),
            'aliases' => count(Platform::registries()->aliases->all()),
            'compatibilityAdapters' => count(Platform::compatibility()->all()),
        ];
    }
}
