KeekoTools::getDefaultCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.2963

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
ccs 2
cts 6
cp 0.3333
cc 1
eloc 15
nc 1
nop 0
crap 1.2963
1
<?php
2
namespace keeko\tools;
3
4
use keeko\tools\command\GenerateActionCommand;
5
use keeko\tools\command\GenerateApiCommand;
6
use keeko\tools\command\GenerateDomainCommand;
7
use keeko\tools\command\GenerateEmberAbilitiesCommand;
8
use keeko\tools\command\GenerateEmberModelsCommand;
9
use keeko\tools\command\GenerateModelsCommand;
10
use keeko\tools\command\GenerateResponderCommand;
11
use keeko\tools\command\GenerateSerializerCommand;
12
use keeko\tools\command\InitCommand;
13
use keeko\tools\command\MagicCommand;
14
use Symfony\Component\Console\Application;
15
use Symfony\Component\Console\ConsoleEvents;
16
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
17
use Symfony\Component\EventDispatcher\EventDispatcher;
18
use keeko\tools\command\GenerateEmberSerializerCommand;
19
use keeko\tools\command\GenerateEmberCommand;
20
21
class KeekoTools extends Application {
22
23
	protected $finishedCommands = [];
24 20
25 20
	protected $keekoDispatcher = null;
26
27 20
	/* (non-PHPdoc)
28 20
	 * @see \Symfony\Component\Console\Application::__construct()
29 20
	*/
30
	public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') {
31 20
		parent::__construct($name, $version);
32
33
		$dispatcher = new EventDispatcher();
34 20
		$this->setDispatcher($dispatcher);
35 20
		$this->keekoDispatcher = $dispatcher;
36
37 20
		$dispatcher->addListener(ConsoleEvents::TERMINATE, function(ConsoleTerminateEvent $event) {
38 20
			$command = $event->getCommand();
39 20
			$this->finishedCommands[] = $command->getName();
40 20
		});
41 20
	}
42 20
43 20
	protected function getDefaultCommands() {
44
		$cmds = parent::getDefaultCommands();
45 20
		$cmds[] = new InitCommand();
46
		$cmds[] = new GenerateModelsCommand();
47
		$cmds[] = new GenerateActionCommand();
48
		$cmds[] = new GenerateDomainCommand();
49
		$cmds[] = new GenerateSerializerCommand();
50
		$cmds[] = new GenerateResponderCommand();
51
		$cmds[] = new GenerateApiCommand();
52
		$cmds[] = new GenerateEmberModelsCommand();
53
		$cmds[] = new GenerateEmberAbilitiesCommand();
54
		$cmds[] = new GenerateEmberSerializerCommand();
55
		$cmds[] = new GenerateEmberCommand();
56
		$cmds[] = new MagicCommand();
57
58
		return $cmds;
59
	}
60
61
	public function commandRan($name) {
62
		return in_array($name, $this->finishedCommands);
63
	}
64
65
	public function getDispatcher() {
66
		return $this->keekoDispatcher;
67
	}
68
}
69