|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This file is part of Laravel Zero. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Nuno Maduro <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace LaravelZero\Framework\Commands; |
|
15
|
|
|
|
|
16
|
|
|
use LogicException; |
|
17
|
|
|
use function strlen; |
|
18
|
|
|
use function str_repeat; |
|
19
|
|
|
use function func_get_args; |
|
20
|
|
|
use NunoMaduro\LaravelConsoleMenu\Menu; |
|
21
|
|
|
use Illuminate\Console\Scheduling\Schedule; |
|
22
|
|
|
use Illuminate\Console\Command as BaseCommand; |
|
23
|
|
|
|
|
24
|
|
|
abstract class Command extends BaseCommand |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Holds an instance of the app, if any. |
|
28
|
|
|
* |
|
29
|
|
|
* @var \LaravelZero\Framework\Application |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $app; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Execute the console command. |
|
35
|
|
|
* |
|
36
|
|
|
* @return void |
|
37
|
|
|
* |
|
38
|
|
|
* @throws \LogicException |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function handle(): void |
|
41
|
|
|
{ |
|
42
|
1 |
|
throw new LogicException('You must override the handle() method in the concrete command class.'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Define the command's schedule. |
|
47
|
|
|
* |
|
48
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
29 |
|
public function schedule(Schedule $schedule): void |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
29 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
29 |
|
public function setLaravel($laravel): void |
|
60
|
|
|
{ |
|
61
|
29 |
|
parent::setLaravel($this->app = $laravel); |
|
62
|
29 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
/* |
|
65
|
|
|
* Returns a menu builder. |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $title |
|
68
|
|
|
* @param array $options |
|
69
|
|
|
* |
|
70
|
|
|
* @return \NunoMaduro\LaravelConsoleMenu\Menu |
|
71
|
|
|
*/ |
|
72
|
|
|
public function menu(string $title, array $options = []): Menu |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->__call('menu', func_get_args()); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/* |
|
78
|
|
|
* Performs the given task, outputs and |
|
79
|
|
|
* returns the result. |
|
80
|
|
|
* |
|
81
|
|
|
* @param string $title |
|
82
|
|
|
* @param callable|null $task |
|
83
|
|
|
* |
|
84
|
|
|
* @return bool With the result of the task. |
|
85
|
|
|
*/ |
|
86
|
13 |
|
public function task(string $title = '', $task = null): bool |
|
87
|
|
|
{ |
|
88
|
13 |
|
return $this->__call('task', func_get_args()); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Displays a title. |
|
93
|
|
|
* |
|
94
|
|
|
* @param string $title |
|
95
|
|
|
* |
|
96
|
|
|
* @return \LaravelZero\Framework\Commands\Command |
|
97
|
|
|
*/ |
|
98
|
2 |
|
public function title(string $title): Command |
|
99
|
|
|
{ |
|
100
|
2 |
|
$size = strlen($title); |
|
101
|
2 |
|
$spaces = str_repeat(' ', $size); |
|
102
|
|
|
|
|
103
|
2 |
|
$this->output->newLine(); |
|
104
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>"); |
|
105
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$title$spaces</>"); |
|
106
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>"); |
|
107
|
2 |
|
$this->output->newLine(); |
|
108
|
|
|
|
|
109
|
2 |
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.