Conditions | 5 |
Paths | 3 |
Total Lines | 53 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
39 | public function __invoke(MonthlyBillableQuery $query) |
||
40 | { |
||
41 | $sql = 'SELECT flights.*, usr.rowid as usrRowId, usr.lastname as lastname, usr.firstname as firstname FROM llx_bbc_vols as flights INNER JOIN llx_user as usr ON flights.fk_receiver = usr.rowid'; |
||
42 | $sql .= ' WHERE '; |
||
43 | $sql .= ' flights.fk_type = 2 '; |
||
44 | $sql .= ' AND flights.is_facture = 0 '; |
||
45 | $sql .= sprintf(' AND YEAR(flights.date) = %s ', $query->getYear()); |
||
46 | $sql .= sprintf(' AND MONTH(flights.date) = %s', $query->getMonth()); |
||
47 | |||
48 | $resql = $this->db->query($sql); |
||
49 | $array = new MonthBillCollection(); |
||
50 | |||
51 | if ($resql) { |
||
52 | $num = $this->db->num_rows($resql); |
||
53 | $i = 0; |
||
54 | if ($num) { |
||
55 | while ($i < $num) { |
||
56 | $obj = $this->db->fetch_object($resql); |
||
57 | if ($obj) { |
||
58 | |||
59 | $flight = new Bbcvols($this->db); |
||
60 | $flight->id = $obj->idBBC_vols; |
||
61 | $flight->idBBC_vols = $obj->idBBC_vols; |
||
62 | $flight->date = $this->db->jdate($obj->date); |
||
63 | $flight->lieuD = $obj->lieuD; |
||
64 | $flight->lieuA = $obj->lieuA; |
||
65 | $flight->heureD = $obj->heureD; |
||
66 | $flight->heureA = $obj->heureA; |
||
67 | $flight->BBC_ballons_idBBC_ballons = $obj->BBC_ballons_idBBC_ballons; |
||
68 | $flight->nbrPax = $obj->nbrPax; |
||
69 | $flight->remarque = $obj->remarque; |
||
70 | $flight->incidents = $obj->incidents; |
||
71 | $flight->fk_type = $obj->fk_type; |
||
72 | $flight->fk_pilot = $obj->fk_pilot; |
||
73 | $flight->fk_organisateur = $obj->fk_organisateur; |
||
74 | $flight->is_facture = $obj->is_facture; |
||
75 | $flight->kilometers = $obj->kilometers; |
||
76 | $flight->cost = $obj->cost; |
||
77 | $flight->fk_receiver = $obj->fk_receiver; |
||
78 | $flight->justif_kilometers = $obj->justif_kilometers; |
||
79 | $flight->date_creation = $obj->date_creation; |
||
80 | $flight->date_update = $obj->date_update; |
||
81 | |||
82 | $moneyReceiver = new MoneyReceiver($obj->firstname, $obj->lastname, $obj->usrRowId); |
||
83 | $array->addFlight($moneyReceiver, $flight); |
||
84 | } |
||
85 | $i++; |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | |||
90 | return $array; |
||
91 | } |
||
92 | |||
93 | } |