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

ToManyRelationshipRemoveActionGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

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 31
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 23 23 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;
3
4
use gossi\codegen\model\PhpClass;
5
use keeko\tools\generator\AbstractActionGenerator;
6
use Propel\Generator\Model\Table;
7
8 View Code Duplication
class ToManyRelationshipRemoveActionGenerator extends AbstractActionGenerator {
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
	/**
11
	 * Add default blank methods
12
	 * 
13
	 * @param PhpClass $class
14
	 */
15
	public function generate(PhpClass $class, Table $model, Table $foreignModel, Table $middle) {
0 ignored issues
show
Unused Code introduced by
The parameter $middle is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
		// add use statements
17
		$this->ensureBasicSetup($class);
18
		
19
		// 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...
20
		$this->addConfigureParamsMethod($class, $this->twig->render('relationship-configureParams.twig'));
21
22
		// method: run(Request $request) : Response
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% 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...
23
		$class->addUseStatement('Symfony\\Component\\HttpFoundation\\Request');
24
		$class->addUseStatement('Symfony\\Component\\HttpFoundation\\Response');
25
		$class->addUseStatement('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException');
26
		$class->addUseStatement('Tobscure\\JsonApi\\Exception\\InvalidParameterException');
27
		$class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName() . 'Query');
28
		$class->addUseStatement($model->getNamespace() . '\\' . $foreignModel->getPhpName() . 'Query');
29
		$class->setMethod($this->generateRunMethod($this->twig->render('to-many-delete-run.twig', [
30
			'model' => $model->getCamelCaseName(),
31
			'class' => $model->getPhpName(),
32
			'foreign_model' => $foreignModel->getCamelCaseName(),
33
			'foreign_class' => $foreignModel->getPhpName()
34
		])));
35
36
		return $class;
37
	}
38
}