Skip to content

Commit

Permalink
refactor: use set and call (remove DI\autowire)
Browse files Browse the repository at this point in the history
  • Loading branch information
SonyPradana committed Jun 3, 2024
1 parent b780c92 commit 5618a78
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/System/Integrate/Console/Karnel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ public function handle($arguments)
$commands = array_merge($commands, $cmd->patterns(), $cmd->cmd());

if ($cmd->isMatch($baseArgs)) {
$this->app->set(
$cmd->class(),
\DI\autowire($cmd->class())->constructor($arguments, $cmd->defaultOption())
);
$class = $cmd->class();
$this->app->set($class, fn () => new $class($arguments, $cmd->defaultOption()));

$service = $this->app->get($cmd->class());
$this->app->call($cmd->call());
$call = $this->app->call($cmd->call());

return $this->exit_code = $service->exit ?? 0;
return $this->exit_code = (is_int($call) ? $call : 0);
}
}

Expand Down

0 comments on commit 5618a78

Please sign in to comment.