1 | <?php |
||
15 | class Run implements RunnerContract |
||
16 | { |
||
17 | protected $artisanCommand; |
||
18 | |||
19 | protected $options; |
||
20 | |||
21 | private $errorMessages = []; |
||
22 | |||
23 | public function __construct(Command $artisanCommand) |
||
24 | { |
||
25 | $this->artisanCommand = $artisanCommand; |
||
26 | this->options = $artisanCommand->option('options'); |
||
|
|||
27 | } |
||
28 | |||
29 | public function errorMessages(): array |
||
30 | { |
||
31 | return $this->errorMessages; |
||
32 | } |
||
33 | |||
34 | private function run(Action $action) |
||
35 | { |
||
36 | $action(); |
||
37 | |||
38 | if ($action->failed()) { |
||
39 | $this->errorMessages[] = $action->errorMessage(); |
||
40 | } |
||
41 | |||
42 | return $this; |
||
43 | } |
||
44 | |||
45 | public function doneWithErrors(): bool |
||
46 | { |
||
47 | return ! empty($this->errorMessages); |
||
48 | } |
||
49 | |||
50 | public function artisan(string $command, array $arguments = []): RunnerContract |
||
51 | { |
||
52 | return $this->run(new Artisan($this->artisanCommand, $command, $arguments)); |
||
53 | } |
||
54 | |||
55 | public function publish($providers, bool $force = false): RunnerContract |
||
56 | { |
||
57 | return $this->run(new Publish($this->artisanCommand, $providers, $force)); |
||
58 | } |
||
59 | |||
60 | public function publishForce($providers): RunnerContract |
||
61 | { |
||
62 | return $this->publish($providers, true); |
||
63 | } |
||
64 | |||
65 | public function publishTag($tag, bool $force = false): RunnerContract |
||
66 | { |
||
67 | return $this->run(new PublishTag($this->artisanCommand, $tag, $force)); |
||
68 | } |
||
69 | |||
70 | public function publishTagForce($tag): RunnerContract |
||
71 | { |
||
72 | return $this->publishTag($tag, true); |
||
73 | } |
||
74 | |||
75 | public function external(string $command, ...$arguments): RunnerContract |
||
76 | { |
||
77 | return $this->run(new External($this->artisanCommand, $command, $arguments)); |
||
78 | } |
||
79 | |||
80 | public function callable(callable $function, ...$arguments): RunnerContract |
||
81 | { |
||
82 | return $this->run(new Callback($this->artisanCommand, $function, $arguments)); |
||
83 | } |
||
84 | |||
85 | public function dispatch($job): RunnerContract |
||
86 | { |
||
87 | return $this->run(new Dispatch($this->artisanCommand, $job)); |
||
88 | } |
||
89 | |||
90 | public function dispatchNow($job): RunnerContract |
||
91 | { |
||
92 | return $this->run(new Dispatch($this->artisanCommand, $job, true)); |
||
100 |