FormatterCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 43
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 22 1
A execute() 0 13 3
1
<?php
2
namespace gossi\formatter\commands;
3
4
use gossi\formatter\Formatter;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class FormatterCommand extends Command {
12
13
	/* (non-PHPdoc)
14
	 * @see \Symfony\Component\Console\Command\Command::configure()
15
	 */
16
	protected function configure() {
17
		$this
18
			->setName('format')
19
			->setDescription('Beautify PHP Code')
20
			->addArgument(
21
				'input',
22
				InputArgument::REQUIRED,
23
				'The input'
24
			)
25
// 			->addArgument(
26
// 				'output',
27
// 				InputArgument::OPTIONAL,
28
// 				'The output'
29
// 			)
30
			->addOption(
31
				'profile',
32
				null,
33
				InputOption::VALUE_OPTIONAL,
34
				'The profile with the formatting options'
35
			)
36
		;
37
	}
38
39
	protected function execute(InputInterface $in, OutputInterface $output) {
40
		$in = $in->getArgument('input');
41
// 		$out = $in->getArgument('output');
42
43
		$code = file_exists($in) ? file_get_contents($in) : null;
44
45
		if ($code !== null) {
46
			$formatter = new Formatter();
47
			$beauty = $formatter->format($code);
48
49
			echo $output->writeln($beauty);
50
		}
51
	}
52
53
}
54