|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace SetBased\Audit\Style; |
|
5
|
|
|
|
|
6
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Output decorator based on Symfony Style Guide. |
|
13
|
|
|
*/ |
|
14
|
|
|
class AuditStyle extends SymfonyStyle |
|
15
|
|
|
{ |
|
16
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
17
|
|
|
/** |
|
18
|
|
|
* @inheritdoc |
|
19
|
|
|
*/ |
|
20
|
31 |
|
public function __construct(InputInterface $input, OutputInterface $output) |
|
21
|
|
|
{ |
|
22
|
31 |
|
parent::__construct($input, $output); |
|
23
|
|
|
|
|
24
|
|
|
// Create style notes. |
|
25
|
31 |
|
$style = new OutputFormatterStyle('yellow'); |
|
26
|
31 |
|
$output->getFormatter() |
|
27
|
|
|
->setStyle('note', $style); |
|
28
|
|
|
|
|
29
|
31 |
|
// Create style for database objects. |
|
30
|
31 |
|
$style = new OutputFormatterStyle('green', null, ['bold']); |
|
31
|
|
|
$output->getFormatter() |
|
32
|
|
|
->setStyle('dbo', $style); |
|
33
|
31 |
|
|
|
34
|
31 |
|
// Create style for file and directory names. |
|
35
|
|
|
$style = new OutputFormatterStyle(null, null, ['bold']); |
|
36
|
|
|
$output->getFormatter() |
|
37
|
31 |
|
->setStyle('fso', $style); |
|
38
|
31 |
|
|
|
39
|
31 |
|
// Create style for SQL statements. |
|
40
|
|
|
$style = new OutputFormatterStyle('magenta', null, ['bold']); |
|
41
|
|
|
$output->getFormatter() |
|
42
|
|
|
->setStyle('sql', $style); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
46
|
|
|
/** |
|
47
|
27 |
|
* Logs a message if verbosity is OutputInterface::VERBOSITY_NORMAL or higher. |
|
48
|
|
|
* |
|
49
|
27 |
|
* This method takes arguments like sprintf. |
|
50
|
|
|
*/ |
|
51
|
27 |
|
public function logInfo(): void |
|
52
|
27 |
|
{ |
|
53
|
|
|
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL) |
|
54
|
27 |
|
{ |
|
55
|
|
|
$args = func_get_args(); |
|
56
|
27 |
|
$format = array_shift($args); |
|
57
|
|
|
|
|
58
|
|
|
$this->writeln(vsprintf('<info>'.$format.'</info>', $args)); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
63
|
|
|
/** |
|
64
|
30 |
|
* Logs a message if verbosity is OutputInterface::VERBOSITY_VERBOSE or higher. |
|
65
|
|
|
* |
|
66
|
30 |
|
* This method takes arguments like sprintf. |
|
67
|
|
|
*/ |
|
68
|
3 |
|
public function logVerbose(): void |
|
69
|
3 |
|
{ |
|
70
|
|
|
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERBOSE) |
|
71
|
3 |
|
{ |
|
72
|
|
|
$args = func_get_args(); |
|
73
|
30 |
|
$format = array_shift($args); |
|
74
|
|
|
|
|
75
|
|
|
$this->writeln(vsprintf('<info>'.$format.'</info>', $args)); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
80
|
|
|
/** |
|
81
|
35 |
|
* Logs a message if verbosity is OutputInterface::VERBOSITY_VERY_VERBOSE or higher. |
|
82
|
|
|
* |
|
83
|
35 |
|
* This method takes arguments like sprintf. |
|
84
|
|
|
*/ |
|
85
|
6 |
|
public function logVeryVerbose(): void |
|
86
|
6 |
|
{ |
|
87
|
|
|
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERY_VERBOSE) |
|
88
|
6 |
|
{ |
|
89
|
|
|
$args = func_get_args(); |
|
90
|
35 |
|
$format = array_shift($args); |
|
91
|
|
|
|
|
92
|
|
|
$this->writeln(vsprintf('<info>'.$format.'</info>', $args)); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
//---------------------------------------------------------------------------------------------------------------------- |
|
100
|
|
|
|