本文整理汇总了PHP中Command::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::factory方法的具体用法?PHP Command::factory怎么用?PHP Command::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
public static function factory($command, $path = 'M/commands/')
{
$path = APP_ROOT . 'app/' . APP_NAME . '/commands/';
return parent::factory($command, $path);
}
示例2: testDurationFloat
public function testDurationFloat()
{
$delay = 1;
$command = Command::factory("sleep")->argument($delay)->run();
$duration = $command->getDuration(true);
$this->assertInternalType('float', $duration);
$this->assertGreaterThanOrEqual(0.9, $duration);
}
示例3: execute
public function execute($params)
{
if (is_array($params) && count($params) > 0) {
$command = array_shift($params);
$exec = Command::factory($command);
$exec->longHelp($params);
} else {
$this->line('This command displays global help text or specific help text for a command if provided');
$this->line('Usage:');
$this->line('help');
$this->line(' Displays this help');
$this->line('help [COMMAND_NAME]');
$this->line(' Displays specific and longer help for [COMMAND_NAME]');
$this->line('help [COMMAND_NAME] [SUBCOMMAND_NAME] and so on....');
$this->line(' Displays specific and longer help for [SUBCOMMAND_NAME] if [COMMAND_NAME] contains some subcommands (e.g. the plugin command)');
$this->line('==========');
$this->line('Here is the list of available root commands:');
$dir = dirname(realpath(__FILE__));
foreach (FileUtils::getAllFiles($dir, 'php') as $afile) {
$subcname = basename($afile, '.php');
$subc = Command::factory($subcname);
$this->line('====== ' . $subcname . ' ======');
$subc->shortHelp();
}
}
}