for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace nebula\runnable;
use nebula\runnable\target\FileTarget;
use nebula\runnable\target\MethodTarget;
use nebula\runnable\target\ClosureTarget;
use nebula\runnable\target\TargetBuilder;
use nebula\runnable\target\FunctionTarget;
use nebula\runnable\target\RunnableTarget;
/**
* 可执行命令表达式
*
*/
class Runnable {
* 运行对象
* @var FunctionTarget|MethodTarget|FileTarget|ClosureTarget
protected $target;
public function __construct($runnable, array $parameter=[]) {
$this->target = TargetBuilder::build($runnable, $parameter);
}
* Get 运行对象
* @return FunctionTarget|MethodTarget|FileTarget|ClosureTarget
public function getTarget()
{
return $this->target;
* 获取名字
* @return string
public function getName()
return $this->target->getName();
* 是否可执行
* @return boolean
public function isVaild():bool
return $this->target->isVaild();
* 执行代码
* @param mixed ...$args
* @return mixed
public function run(...$args) {
return $this->apply($args);
* @param array $parameter
public function apply(array $parameter) {
return $this->target->apply($parameter);
public static function newClassInstance(string $class)
return TargetBuilder::newClassInstance($class);