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

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
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
use Propel\Generator\Model\Table;
8
9 View Code Duplication
class ToOneRelationshipJsonResponseGenerator 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...
10
	
11
	/** @var Table */
12
	private $model;
13
	
14
	/** @var Table */
15
	private $foreign;
16
	
17
	public function __construct($service, Table $model, Table $foreign) {
18
		parent::__construct($service);
19
		$this->model = $model;
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...
20
		$this->foreign = $foreign;
21
	}
22
23
	protected function addMethods(PhpClass $class, ActionSchema $action) {
0 ignored issues
show
Unused Code introduced by
The parameter $action 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...
24
		// 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...
25
		$class->addUseStatement($this->model->getNamespace() . '\\' . $this->model->getPhpName());
26
		$class->setMethod($this->generateRunMethod($this->twig->render('dump-to-one-relationship.twig', [
27
			'class' => $this->model->getPhpName(),
28
			'related' => $this->foreign->getCamelCaseName()
29
		])));
30
	}
31
}