| Conditions | 4 |
| Paths | 3 |
| Total Lines | 23 |
| Lines | 23 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function query($year) |
||
| 31 | { |
||
| 32 | $sql = 'SELECT SUM(damage.amount) as total_amount, damage.author_id as author'; |
||
| 33 | $sql.=' FROM '.MAIN_DB_PREFIX.'bbc_flight_damages as damage'; |
||
| 34 | $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'bbc_vols as flight ON flight.rowid = damage.flight_id'; |
||
| 35 | $sql.=' WHERE YEAR(flight.date) = '.$this->db->escape($year); |
||
| 36 | $sql.=' GROUP BY damage.author_id'; |
||
| 37 | |||
| 38 | $damages = []; |
||
| 39 | |||
| 40 | $resql = $this->db->query($sql); |
||
| 41 | if ($resql) { |
||
| 42 | $num = $this->db->num_rows($resql); |
||
| 43 | if ($num) { |
||
| 44 | for($i = 0; $i < $num ; $i++) { |
||
| 45 | $properties = $this->db->fetch_array($resql); |
||
| 46 | $damages[] = TotalDamage::fromArray($properties); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | return $damages; |
||
| 52 | } |
||
| 53 | } |
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.