Completed
Push — master ( 98cd2e...56265b )
by Thomas
09:01
created

ensureUseStatements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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