<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class ProjectionRebuildCommand extends AbstractCommand
{
    public function name(): string { return 'projection:rebuild'; }
    public function description(): string { return 'PPphp Projection Rebuild'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Projection Rebuild');
        $runtime = \PpPhp\Core\Platform\Event\Sourcing\Projection\ProjectionRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); if (($runtime->readModel('console_projection')) === null) { $runtime->register(\PpPhp\Core\Platform\Event\Sourcing\Projection\ProjectionDefinition::create('console_projection', 'Console Projection', [], [])); } $processed = $runtime->rebuild('console_projection'); $this->line('Rebuilt: YES'); $this->line('Processed: ' . $processed);
        return 0;
    }
}
