Completed
Push — master ( 17137d...17de33 )
by Thomas
08:11
created

ensureUseStatements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
namespace keeko\tools\generator;
3
4
use gossi\codegen\model\PhpTrait;
5
use keeko\core\schema\ActionSchema;
6
use keeko\tools\generator\AbstractActionGenerator;
7
use gossi\codegen\model\AbstractPhpStruct;
8
9
class AbstractActionTraitGenerator extends AbstractActionGenerator {
10
	
11
	/**
12
	 * Generates an action trait with the given name as classname
13
	 * 
14
	 * @param string $name
15
	 * @param ActionSchema $action
16
	 * @return PhpTrait
17 5
	 */
18 5
	public function generate($name, ActionSchema $action) {
19 5
		$trait = PhpTrait::create($name)
20 5
			->setDescription('Base methods for ' . $action->getClass())
21
			->setLongDescription('This code is automatically created. Modifications will probably be overwritten.');
22 5
	
23 5
		$this->ensureUseStatements($trait);
24
		$this->addMethods($trait, $action);
25 5
26
		return $trait;
27
	}
28
29
	protected function addMethods(PhpTrait $struct, ActionSchema $action) {
30
	}
31
	
32
	protected function ensureUseStatements(AbstractPhpStruct $struct) {
33
		parent::ensureUseStatements($struct);
34
		$struct->removeUseStatement('keeko\\core\\package\\AbstractAction');
35
		$struct->addUseStatement('Symfony\\Component\\HttpFoundation\\Request');
36
		$struct->addUseStatement('Symfony\\Component\\HttpFoundation\\Response');
37
	}
38
}