<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class EventStoreCompactCommand extends AbstractCommand
{
    public function name(): string { return 'eventstore:compact'; }
    public function description(): string { return 'PPphp Event Store Compact'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Event Store Compact');
        $result = \PpPhp\Core\Platform\Event\Sourcing\Compaction\EventCompactionRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath())->compactAggregate('compact-order-1'); $this->line('Compacted: ' . $result->compactedCount());
        return 0;
    }
}
