2024-01-01 00:45:31 +04:00
|
|
|
<?php
|
2024-04-04 22:57:10 +04:00
|
|
|
namespace nur\sery\wip\cli;
|
2024-01-01 00:45:31 +04:00
|
|
|
|
|
|
|
use nur\sery\php\func;
|
|
|
|
|
|
|
|
class DynamicCommandMethod implements IDynamicCommand {
|
|
|
|
function __construct($func) {
|
|
|
|
$this->func = $func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var object */
|
|
|
|
private $dest;
|
|
|
|
|
|
|
|
function setDest($dest): void {
|
|
|
|
if (!is_object($dest)) $dest = null;
|
|
|
|
$this->dest = $dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCommands(): ?array {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private $func;
|
|
|
|
|
|
|
|
function getCommandDefs(string $command, bool $virtual): ?array {
|
|
|
|
$func = $this->func;
|
|
|
|
$func_args = [$command];
|
|
|
|
func::check_func($func, $this->dest, $func_args);
|
|
|
|
return func::call($func, ...$func_args);
|
|
|
|
}
|
|
|
|
}
|