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

ModelCreateJsonResponderGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethods() 0 16 1
1
<?php
2
namespace keeko\tools\generator\responder;
3
4
use gossi\codegen\model\PhpClass;
5
use keeko\framework\schema\ActionSchema;
6
7
class ModelCreateJsonResponderGenerator extends AbstractModelJsonResponderGenerator {
8
9
	protected function addMethods(PhpClass $class, ActionSchema $action) {
10
		$this->generateGetPayloadMethods($class, $this->twig->render('getPayloadMethods-create.twig'));
11
		$this->generateNotValid($class);
12
		
13
		// method: created(Request $request, PayloadInterface $payload)
1 ignored issue
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
14
		$modelName = $this->modelService->getModelNameByAction($action);
15
		$model = $this->modelService->getModel($modelName);
16
17
		$created = $this->generatePayloadMethod('created', $this->twig->render('model-created.twig', [
18
			'class' => $model->getPhpName()
19
		]));
20
		$class->setMethod($created);
21
		$class->addUseStatement('Tobscure\\JsonApi\\Document');
22
		$class->addUseStatement('Tobscure\\JsonApi\\Resource');
23
		$class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName());
24
	}
25
}