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