Passed
Push — master ( 46e706...05f68d )
by Anthony
03:09
created

Faction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
	namespace modules\bataille\app\controller;
3
	
4
	
5
	use core\App;
6
	
7
	class Faction {
8
		private $id_faction;
9
		
10
		//-------------------------- BUILDER ----------------------------------------------------------------------------//
11
		public function __construct() {
12
			
13
		}
14
		//-------------------------- END BUILDER ----------------------------------------------------------------------------//
15
		
16
		
17
		//-------------------------- GETTER ----------------------------------------------------------------------------//
18
		/**
19
		 * @return mixed
20
		 * fonction qui renvoi l'ID de la faction du joueur
21
		 */
22
		public function getFactionPlayer() {
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...
23
			$dbc = App::getDb();
24
			
25
			$query = $dbc->select("ID_faction")->from("_bataille_infos_player")
26
				->where("ID_identite", "=", Bataille::getIdIdentite(), "AND")
27
				->where("ID_faction", ">", 0)
28
				->get();
29
			
30
			if ((count($query) > 0)) {
31
				foreach ($query as $obj) {
32
					$this->id_faction = $obj->ID_faction;
33
					$this->getInfosFaction();
34
				}
35
			}
36
		}
37
		
38
		/**
39
		 * @param null $id_faction
40
		 * fonction qui récupère les infos de la faction
41
		 */
42
		public function getInfosFaction($id_faction = null) {
0 ignored issues
show
Unused Code introduced by
The parameter $id_faction 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...
43
			$dbc = App::getDb();
44
			
45
			$id_faction = $this->id_faction;
46
			
47
			$query = $dbc->select("identite.pseudo")
48
				->select("_bataille_faction.nom_faction")
49
				->select("_bataille_faction.img_profil")
50
				->select("_bataille_faction.description")
51
				->from("_bataille_faction")
52
				->from("identite")
53
				->where("_bataille_faction.ID_faction", "=", $id_faction, "AND")
54
				->where("_bataille_faction.ID_identite", "=", "identite.ID_identite", "", true)
55
				->get();
56
			
57
			if ((count($query) == 1)) {
58
				foreach ($query as $obj) {
59
					Bataille::setValues(["faction" => [
60
						"nom" => $obj->nom_faction,
61
						"description" => $obj->description,
62
						"url_img" => $obj->img_profil,
63
						"pseudo_chef" => $obj->pseudo
64
					]]);
65
				}
66
			}
67
		}
68
		//-------------------------- END GETTER ----------------------------------------------------------------------------//
69
		
70
		
71
		//-------------------------- SETTER ----------------------------------------------------------------------------//
72
		//-------------------------- END SETTER ----------------------------------------------------------------------------//    
73
	}