Completed
Push — master ( 2fb143...d99a08 )
by Thomas
09:36
created

AbstractJsonResponderGenerator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 28
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\responder;
3
4
use gossi\codegen\model\AbstractPhpStruct;
5
use keeko\framework\schema\ActionSchema;
6
7
class AbstractJsonResponderGenerator extends AbstractResponderGenerator {
8
9
	protected function getTemplateFolder() {
10
		return 'responder/json';
11
	}
12
	
13
	protected function ensureUseStatements(AbstractPhpStruct $struct) {
14
		parent::ensureUseStatements($struct);
15
		$struct->removeUseStatement('Symfony\\Component\\HttpFoundation\\Response');
16
		$struct->addUseStatement('Symfony\\Component\\HttpFoundation\\JsonResponse');
17
	}
18
	
19
	protected function generateRunMethod($body = '') {
20
		$method = parent::generateRunMethod($body);
21
		$method->setType('JsonResponse');
22
		return $method;
23
	}
24
25
	/**
26
	 * 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