<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DecisionTableEvaluateCommand extends AbstractCommand
{
    public function name(): string { return 'rules:decide'; }
    public function description(): string { return 'PPphp Decision Table Evaluate'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Decision Table Evaluate');
        $runtime = \PpPhp\Core\Platform\Rules\RulesRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $runtime->registerDecisionTable(\PpPhp\Core\Platform\Rules\DecisionTable::create('console_decision_table', 'Console Decision Table', ['enabled'], ['decision'], [['rowId' => 'row_allow', 'conditions' => [\PpPhp\Core\Platform\Rules\RuleCondition::create('enabled', 'equals', true)->toArray()], 'outputs' => ['decision' => 'allow']]])); $result = $runtime->decide('console_decision_table', ['enabled' => true]); $this->line('Matched: ' . ($result->matched() ? 'YES' : 'NO'));
        return 0;
    }
}
