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

AuditStyle   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 84
ccs 28
cts 40
cp 0.7
rs 10
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A logVeryVerbose() 0 8 2
A logInfo() 0 8 2
A logVerbose() 0 8 2
A logNote() 0 8 2
A logDebug() 0 8 2
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