Completed
Push — master ( 1f7a6d...d6c443 )
by P.R.
03:14
created

AuditStyle::logVerbose()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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