Completed
Push — master ( b111ad...5ca753 )
by P.R.
05:18 queued 43s
created

AuditStyle::logNote()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 6
rs 10
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 26
  public function __construct(InputInterface $input, OutputInterface $output)
21
  {
22 26
    parent::__construct($input, $output);
23
24
    // Create style notes.
25 26
    $style = new OutputFormatterStyle('yellow');
26 26
    $output->getFormatter()->setStyle('note', $style);
27
28
    // Create style for database objects.
29 26
    $style = new OutputFormatterStyle('green', null, ['bold']);
30 26
    $output->getFormatter()->setStyle('dbo', $style);
31
32
    // Create style for file and directory names.
33 26
    $style = new OutputFormatterStyle(null, null, ['bold']);
34 26
    $output->getFormatter()->setStyle('fso', $style);
35
36
    // Create style for SQL statements.
37 26
    $style = new OutputFormatterStyle('magenta', null, ['bold']);
38 26
    $output->getFormatter()->setStyle('sql', $style);
39 26
  }
40
41
  //--------------------------------------------------------------------------------------------------------------------
42
  public function logDebug()
43
  {
44
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_DEBUG)
45
    {
46
      $args   = func_get_args();
47
      $format = array_shift($args);
48
49
      $this->writeln(vsprintf('<info>'.$format.'</info>', $args));
50
    }
51
  }
52
53
  //--------------------------------------------------------------------------------------------------------------------
54 22
  public function logInfo()
55
  {
56 22
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL)
57
    {
58 22
      $args   = func_get_args();
59 22
      $format = array_shift($args);
60
61 22
      $this->writeln(vsprintf('<info>'.$format.'</info>', $args));
62
    }
63 22
  }
64
65
  //--------------------------------------------------------------------------------------------------------------------
66
  public function logNote()
67
  {
68
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL)
69
    {
70
      $args   = func_get_args();
71
      $format = array_shift($args);
72
73
      $this->writeln('<note> ! [NOTE] '.vsprintf($format, $args).'</note>');
74
    }
75
  }
76
77
  //--------------------------------------------------------------------------------------------------------------------
78 25
  public function logVerbose()
79
  {
80 25
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERBOSE)
81
    {
82 3
      $args   = func_get_args();
83 3
      $format = array_shift($args);
84
85 3
      $this->writeln(vsprintf('<info>'.$format.'</info>', $args));
86
    }
87 25
  }
88
89
  //--------------------------------------------------------------------------------------------------------------------
90 26
  public function logVeryVerbose()
91
  {
92 26
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERY_VERBOSE)
93
    {
94 3
      $args   = func_get_args();
95 3
      $format = array_shift($args);
96
97 3
      $this->writeln(vsprintf('<info>'.$format.'</info>', $args));
98
    }
99 26
  }
100
101
  //--------------------------------------------------------------------------------------------------------------------
102
}
103
104
//----------------------------------------------------------------------------------------------------------------------
105