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 function strlen; |
17
|
|
|
use function str_repeat; |
18
|
|
|
use function func_get_args; |
19
|
|
|
use NunoMaduro\LaravelConsoleMenu\Menu; |
20
|
|
|
use Illuminate\Console\Scheduling\Schedule; |
21
|
|
|
use Illuminate\Console\Command as BaseCommand; |
22
|
|
|
|
23
|
|
|
abstract class Command extends BaseCommand |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Holds an instance of the app, if any. |
27
|
|
|
* |
28
|
|
|
* @var \LaravelZero\Framework\Application |
29
|
|
|
*/ |
30
|
|
|
protected $app; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Define the command's schedule. |
34
|
|
|
* |
35
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
29 |
|
public function schedule(Schedule $schedule) |
|
|
|
|
39
|
|
|
{ |
40
|
29 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
29 |
|
public function setLaravel($laravel): void |
46
|
|
|
{ |
47
|
29 |
|
parent::setLaravel($this->app = $laravel); |
48
|
29 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns a menu builder. |
52
|
|
|
*/ |
53
|
|
|
public function menu(string $title, array $options = []): Menu |
54
|
|
|
{ |
55
|
|
|
return $this->__call('menu', func_get_args()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Performs the given task, outputs and |
60
|
|
|
* returns the result. |
61
|
|
|
*/ |
62
|
13 |
|
public function task(string $title = '', $task = null): bool |
63
|
|
|
{ |
64
|
13 |
|
return $this->__call('task', func_get_args()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/* |
68
|
|
|
* Displays the given string as title. |
69
|
|
|
*/ |
70
|
2 |
|
public function title(string $title): Command |
71
|
|
|
{ |
72
|
2 |
|
$size = strlen($title); |
73
|
2 |
|
$spaces = str_repeat(' ', $size); |
74
|
|
|
|
75
|
2 |
|
$this->output->newLine(); |
76
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>"); |
77
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$title$spaces</>"); |
78
|
2 |
|
$this->output->writeln("<bg=blue;fg=white>$spaces$spaces$spaces</>"); |
79
|
2 |
|
$this->output->newLine(); |
80
|
|
|
|
81
|
2 |
|
return $this; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.