Conditions | 7 |
Paths | 9 |
Total Lines | 64 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
21 | public function __construct($id_base = null, $install_base = null) { |
||
22 | $dbc = App::getDb(); |
||
23 | $temps_trajet = ""; |
||
24 | $map = []; |
||
25 | |||
26 | if ($install_base != null) { |
||
27 | return true; |
||
|
|||
28 | } |
||
29 | |||
30 | if ($id_base == null) { |
||
31 | $this->getParametres(); |
||
32 | |||
33 | $query = $dbc->select("_bataille_base.nom_base") |
||
34 | ->select("_bataille_base.points") |
||
35 | ->select("_bataille_base.posx") |
||
36 | ->select("_bataille_base.posy") |
||
37 | ->select("_bataille_base.ID_base") |
||
38 | ->select("identite.pseudo") |
||
39 | ->select("identite.ID_identite") |
||
40 | ->from("identite") |
||
41 | ->from("_bataille_base") |
||
42 | ->where("_bataille_base.ID_identite", "=", "identite.ID_identite", "", true) |
||
43 | ->get(); |
||
44 | } |
||
45 | else { |
||
46 | $query = $dbc->select("_bataille_base.nom_base") |
||
47 | ->select("_bataille_base.points") |
||
48 | ->select("_bataille_base.posx") |
||
49 | ->select("_bataille_base.posy") |
||
50 | ->select("_bataille_base.ID_base") |
||
51 | ->select("identite.ID_identite") |
||
52 | ->select("identite.pseudo") |
||
53 | ->from("identite") |
||
54 | ->from("_bataille_base") |
||
55 | ->where("_bataille_base.ID_base", "=", $id_base, "AND") |
||
56 | ->where("_bataille_base.ID_identite", "=", "identite.ID_identite", "", true) |
||
57 | ->get(); |
||
58 | |||
59 | $temps_trajet = DateHeure::Secondeenheure(Bataille::getDureeTrajet($id_base)); |
||
60 | } |
||
61 | |||
62 | if ((is_array($query)) && (count($query) > 0)) { |
||
63 | foreach ($query as $obj) { |
||
64 | $ma_base = ""; |
||
65 | if ($obj->ID_base == Bataille::getIdBase()) { |
||
66 | $ma_base = "ma-base"; |
||
67 | } |
||
68 | |||
69 | $map[] = [ |
||
70 | "nom_base" => $obj->nom_base, |
||
71 | "points" => $obj->points, |
||
72 | "posx" => $obj->posx, |
||
73 | "posy" => $obj->posy, |
||
74 | "id_base" => $obj->ID_base, |
||
75 | "id_identite" => $obj->ID_identite, |
||
76 | "pseudo" => $obj->pseudo, |
||
77 | "ma_base" => $ma_base, |
||
78 | "temps_trajet" => $temps_trajet |
||
79 | ]; |
||
80 | } |
||
81 | |||
82 | Bataille::setValues(["map" => $map]); |
||
83 | } |
||
84 | } |
||
85 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
157 | } |