Total Complexity | 7 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class Runnable { |
||
16 | |||
17 | /** |
||
18 | * 运行对象 |
||
19 | * |
||
20 | * @var FunctionTarget|MethodTarget|FileTarget|ClosureTarget |
||
21 | */ |
||
22 | protected $target; |
||
23 | |||
24 | public function __construct($runnable, array $parameter=[]) { |
||
25 | $this->target = TargetBuilder::build($runnable, $parameter); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get 运行对象 |
||
30 | * |
||
31 | * @return FunctionTarget|MethodTarget|FileTarget|ClosureTarget |
||
32 | */ |
||
33 | public function getTarget() |
||
34 | { |
||
35 | return $this->target; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * 获取名字 |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getName() |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * 是否可执行 |
||
50 | * |
||
51 | * @return boolean |
||
52 | */ |
||
53 | public function isVaild():bool |
||
54 | { |
||
55 | return $this->target->isVaild(); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * 执行代码 |
||
60 | * |
||
61 | * @param mixed ...$args |
||
62 | * @return mixed |
||
63 | */ |
||
64 | public function run(...$args) { |
||
65 | return $this->apply($args); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * 执行代码 |
||
70 | * |
||
71 | * @param array $parameter |
||
72 | * @return mixed |
||
73 | */ |
||
74 | public function apply(array $parameter) { |
||
75 | return $this->target->apply($parameter); |
||
76 | } |
||
77 | |||
78 | public static function newClassInstance(string $class) |
||
81 | } |
||
82 | } |