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

ModelUpdateActionTraitGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethods() 0 20 1
1
<?php
2
namespace keeko\tools\generator\action\base;
3
4
use gossi\codegen\model\PhpTrait;
5
use keeko\core\schema\ActionSchema;
6
use keeko\tools\generator\AbstractActionTraitGenerator;
7
use keeko\tools\utils\NameUtils;
8
9
class ModelUpdateActionTraitGenerator extends AbstractActionTraitGenerator {
10
11
	/* (non-PHPdoc)
12
	 * @see \keeko\tools\generator\AbstractTraitGenerator::addMethods()
13
	 */
14
	protected function addMethods(PhpTrait $trait, ActionSchema $action) {
15
		$modelName = $this->modelService->getModelNameByAction($action);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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...
16
		$modelVariableName = NameUtils::toCamelCase($modelName);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
17
		$modelObjectName = NameUtils::toStudlyCase($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...
18
		$fullModelObjectName = $this->modelService->getFullModelObjectName($action);
19
	
20
		// method: configureParams(OptionsResolver $resolver)
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
21
		$this->addConfigureParamsMethod($trait, $this->twig->render('update-configureParams.twig'));
22
	
23
		// method: run(Request $request)
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
24
		$trait->addUseStatement($fullModelObjectName . 'Query');
25
		$trait->addUseStatement('keeko\\core\\exceptions\\ValidationException');
26
		$trait->addUseStatement('keeko\\core\\utils\\HydrateUtils');
27
		$trait->addUseStatement('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException');
28
		$trait->setMethod($this->generateRunMethod($this->twig->render('update-run.twig', [
29
			'model' => $modelVariableName,
30
			'class' => $modelObjectName,
31
			'fields' => $this->codegenService->getWriteFields($modelName)
32
		])));
33
	}
34
}