Command   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A error() 0 4 1
A log() 0 5 2
1
<?php
2
3
namespace Genesis\Commands;
4
5
6
use Genesis\Cli;
7
use Genesis\ErrorException;
8
9
10
/**
11
 * @author Adam Bisek <[email protected]>
12
 */
13
abstract class Command
14
{
15
16
	const SUCCESS = 'success';
17
18
	const ERROR = 'error';
19
20
	private static $severityColors = [
21
		self::SUCCESS => 'green',
22
		self::ERROR => 'red',
23
	];
24
25
26
	/**
27
	 * Trigger an error and ends execution (if not catched)
28
	 * @param $message
29
	 * @throws ErrorException
30
	 */
31 5
	protected function error($message)
32
	{
33 5
		throw new ErrorException($message);
34
	}
35
36
37 9
	protected function log($message, $severity = NULL)
38
	{
39 9
		$color = isset(self::$severityColors[$severity]) ? self::$severityColors[$severity] : NULL;
40 9
		echo Cli::getColoredString($message . PHP_EOL, $color);
41 9
	}
42
43
}