<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class QueryRunCommand extends AbstractCommand
{
    public function name(): string { return 'query:run'; }
    public function description(): string { return 'PPphp Query Run'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Query Run');
        $runtime = \PpPhp\Core\Platform\Event\Sourcing\Query\QueryRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $runtime->register(\PpPhp\Core\Platform\Event\Sourcing\Query\ReadModelDefinition::create('console_read_model', 'console_projection', 'Console Read Model', ['aggregateId', 'state'])); $result = $runtime->query(\PpPhp\Core\Platform\Event\Sourcing\Query\QueryRequest::create('console_read_model', [], 'aggregateId', 'asc', 1, 10)); $this->line('Total: ' . $result->total()); $this->line('Returned: ' . $result->returned());
        return 0;
    }
}
