nur-sery/wip/cli/DynamicCommandMethod.php

32 lines
635 B
PHP
Raw Normal View History

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
2024-09-19 01:01:22 +04:00
use nur\sery\php\nur_func;
2024-01-01 00:45:31 +04:00
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];
2024-09-19 01:01:22 +04:00
nur_func::check_func($func, $this->dest, $func_args);
return nur_func::call($func, ...$func_args);
2024-01-01 00:45:31 +04:00
}
}