Style::success()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 6
1
<?php
2
namespace Tivnet\Console;
3
4
use Symfony\Component\Console\Output\Output;
5
use Symfony\Component\Console\Style\SymfonyStyle;
6
7
8
/**
9
 * Same as SymfonyStyle, but quiet by default. Requires `-v` to start talking.
10
 */
11
class Style extends SymfonyStyle {
12
13
	/**
14
	 * Minimum verbosity level at which any output is displayed.
15
	 */
16
	const MIN_VERBOSITY = Output::VERBOSITY_VERBOSE;
17
18
	/**
19
	 * The error output is forced.
20
	 * {@inheritdoc}
21
	 */
22
	public function error( $message ) {
23
		$old_verbosity = $this->getVerbosity();
24
		$this->setVerbosity( Output::VERBOSITY_NORMAL );
25
		parent::error( $message );
26
		$this->setVerbosity( $old_verbosity );
27
	}
28
29
	/**
30
	 * {@inheritdoc}
31
	 */
32
	public function section( $message ) {
33
		if ( $this->getVerbosity() >= self::MIN_VERBOSITY ) {
34
			parent::section( $message );
35
		}
36
	}
37
38
	/**
39
	 * {@inheritdoc}
40
	 */
41
	public function title( $message ) {
42
		if ( $this->getVerbosity() >= self::MIN_VERBOSITY ) {
43
			parent::title( $message );
44
		}
45
	}
46
47
	/**
48
	 * {@inheritdoc}
49
	 */
50
	public function success( $message ) {
51
		if ( $this->getVerbosity() >= self::MIN_VERBOSITY ) {
52
			parent::success( $message );
53
		}
54
	}
55
}
56