<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class EventVersioningUpcastersCommand extends AbstractCommand
{
    public function name(): string { return 'event:upcasters'; }
    public function description(): string { return 'PPphp Event Upcasters'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Event Upcasters');
        $runtime = \PpPhp\Core\Platform\Event\Sourcing\Versioning\EventVersioningRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); foreach ($runtime->summary()['upcasters'] as $upcaster) { $this->line('- ' . $upcaster['upcasterId'] . ' ' . $upcaster['eventType'] . ' v' . $upcaster['fromVersion'] . '->v' . $upcaster['toVersion']); }
        return 0;
    }
}
