Passed
Push — master ( 70bd22...a47f7f )
by Anthony
03:21
created

RelationFaction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 74.19 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 23
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getListeRelation() 23 23 3

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 modules\bataille\app\controller;
3
	
4
	
5
	use core\App;
6
	
7
	class RelationFaction extends Faction {
8
		//-------------------------- GETTER ----------------------------------------------------------------------------//
9 View Code Duplication
		public function getListeRelation() {
0 ignored issues
show
Duplication introduced by
This method 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
			$dbc = App::getDb();
11
			
12
			$query = $dbc->select()->from("_bataille_faction_relation")
13
				->from("_bataille_faction")
14
				->where("_bataille_faction_relation.ID_faction", "=", $this->id_faction, "AND")
15
				->where("_bataille_faction_relation.ID_autre_faction", "=", "_bataille_faction.ID_faction", "", true)
16
				->get();
17
			
18
			$relations = [];
19
			if (count($query) > 0) {
20
				foreach ($query as $obj) {
21
					$relations[] = [
22
						"id_relation" => $obj->ID_faction_relation,
23
						"relation" => $obj->relation,
24
						"id_autre_faction" => $obj->ID_autre_faction,
25
						"nom_autre_faction" => $obj->nom_faction
26
					];
27
				}
28
			}
29
			
30
			Bataille::setValues(["relations" => $relations]);
31
		}
32
		//-------------------------- END GETTER ----------------------------------------------------------------------------//
33
		
34
		
35
		//-------------------------- SETTER ----------------------------------------------------------------------------//
36
		//-------------------------- END SETTER ----------------------------------------------------------------------------//    
37
	}