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

AbstractJsonResponseGenerator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplateFolder() 0 3 1
A ensureUseStatements() 0 5 1
A generateRunMethod() 0 5 1
A generate() 0 3 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