Completed
Push — master ( c9073d...17137d )
by Thomas
17:02
created

ensureUseStatements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 5
cts 5
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
namespace keeko\tools\generator;
3
4
use gossi\codegen\model\AbstractPhpStruct;
5
use keeko\core\schema\ActionSchema;
6
7
class AbstractJsonResponseGenerator extends AbstractResponseGenerator {
8
9 3
	protected function getTemplateFolder() {
10 3
		return 'response/json';
11
	}
12
	
13 3
	protected function ensureUseStatements(AbstractPhpStruct $struct) {
14 3
		parent::ensureUseStatements($struct);
15 3
		$struct->removeUseStatement('Symfony\\Component\\HttpFoundation\\Response');
16 3
		$struct->addUseStatement('Symfony\\Component\\HttpFoundation\\JsonResponse');
17 3
	}
18
	
19
	protected function generateRunMethod($body = '') {
20
		$method = parent::generateRunMethod($body);
21
		$method->setType('JsonResponse');
22
		return $method;
23
	}
24
25 3
	/**
26 3
	 * Generates a json response class for the given action
27
	 *
28
	 * @param ActionSchema $action
29
	 * @return PhpClass
30
	 */
31
	public function generate(ActionSchema $action) {
32
		return $this->doGenerate($action, 'json');
33
	}
34
}
35