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

ModelDeleteActionTraitGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethods() 17 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
class ModelDeleteActionTraitGenerator extends AbstractActionTraitGenerator {
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...
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('delete-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('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException');
26
		$trait->setMethod($this->generateRunMethod($this->twig->render('delete-run.twig', [
27
			'model' => $modelVariableName,
28
			'class' => $modelObjectName
29
		])));
30
	}
31
32
}
33