Completed
Push — master ( da62ab...2e0a22 )
by Thomas
09:51
created

ModelCreateJsonResponseGenerator::addMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
namespace keeko\tools\generator\response;
3
4
use gossi\codegen\model\PhpClass;
5
use keeko\core\schema\ActionSchema;
6
use keeko\tools\generator\AbstractJsonResponseGenerator;
7
8 View Code Duplication
class ModelCreateJsonResponseGenerator extends AbstractJsonResponseGenerator {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
10
	protected function addMethods(PhpClass $class, ActionSchema $action) {
11
		$modelName = $this->modelService->getModelNameByAction($action);
12
		$model = $this->modelService->getModel($modelName);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
13
14
		// method: run(Request $request, $data = null)
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% 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...
15
		$class->addUseStatement('Tobscure\\JsonApi\\Document');
16
		$class->addUseStatement('Tobscure\\JsonApi\\Resource');
17
		$class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName());
18
		$class->setMethod($this->generateRunMethod($this->twig->render('create-run.twig', [
19
			'class' => $model->getPhpName()
20
		])));
21
	}
22
}