1
|
|
|
<?php namespace Arcanedev\LogViewer\Commands; |
2
|
|
|
|
3
|
|
|
use Arcanedev\LogViewer\Contracts\Utilities\LogChecker as LogCheckerContract; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class PublishCommand |
7
|
|
|
* |
8
|
|
|
* @package Arcanedev\LogViewer\Commands |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class CheckCommand extends Command |
12
|
|
|
{ |
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
14
|
|
|
| Properties |
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* The console command name. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $name = 'log-viewer:check'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The console command description. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $description = 'Check all LogViewer requirements.'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The name and signature of the console command. |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $signature = 'log-viewer:check'; |
37
|
|
|
|
38
|
|
|
/* ------------------------------------------------------------------------------------------------ |
39
|
|
|
| Getter & Setters |
40
|
|
|
| ------------------------------------------------------------------------------------------------ |
41
|
|
|
*/ |
42
|
|
|
/** |
43
|
|
|
* Get the Log Checker instance. |
44
|
|
|
* |
45
|
|
|
* @return \Arcanedev\LogViewer\Contracts\Utilities\LogChecker |
46
|
|
|
*/ |
47
|
3 |
|
protected function getChecker() |
48
|
|
|
{ |
49
|
3 |
|
return $this->laravel[LogCheckerContract::class]; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/* ------------------------------------------------------------------------------------------------ |
53
|
|
|
| Main Functions |
54
|
|
|
| ------------------------------------------------------------------------------------------------ |
55
|
|
|
*/ |
56
|
|
|
/** |
57
|
|
|
* Execute the console command. |
58
|
|
|
*/ |
59
|
3 |
|
public function handle() |
60
|
|
|
{ |
61
|
3 |
|
$this->displayLogViewer(); |
62
|
3 |
|
$this->displayRequirements(); |
63
|
3 |
|
$this->displayMessages(); |
64
|
3 |
|
} |
65
|
|
|
|
66
|
|
|
/* ------------------------------------------------------------------------------------------------ |
67
|
|
|
| Other Functions |
68
|
|
|
| ------------------------------------------------------------------------------------------------ |
69
|
|
|
*/ |
70
|
|
|
/** |
71
|
|
|
* Display LogViewer requirements. |
72
|
|
|
*/ |
73
|
3 |
|
private function displayRequirements() |
74
|
|
|
{ |
75
|
3 |
|
$requirements = $this->getChecker()->requirements(); |
76
|
|
|
|
77
|
3 |
|
$this->frame('Application requirements'); |
78
|
|
|
|
79
|
3 |
|
$this->table([ |
80
|
3 |
|
'Status', 'Message' |
81
|
1 |
|
], [ |
82
|
3 |
|
[$requirements['status'], $requirements['message']] |
83
|
1 |
|
]); |
84
|
3 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Display LogViewer messages. |
88
|
|
|
*/ |
89
|
3 |
|
private function displayMessages() |
90
|
|
|
{ |
91
|
3 |
|
$messages = $this->getChecker()->messages(); |
92
|
|
|
|
93
|
3 |
|
$rows = []; |
94
|
3 |
|
foreach ($messages['files'] as $file => $message) { |
95
|
3 |
|
$rows[] = [$file, $message]; |
96
|
1 |
|
} |
97
|
|
|
|
98
|
3 |
|
$this->frame('LogViewer messages'); |
99
|
3 |
|
$this->table(['File', 'Message'], $rows); |
100
|
3 |
|
} |
101
|
|
|
} |
102
|
|
|
|