Code Duplication    Length = 25-28 lines in 5 locations

require/class.Spotter.php 5 locations

@@ 4082-4107 (lines=26) @@
4079
	* @return Array the aircraft list
4080
	*
4081
	*/
4082
	public function countAllAircraftTypesByAirline($airline_icao)
4083
	{
4084
		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4085
4086
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4087
				FROM spotter_output
4088
				WHERE spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
4089
				GROUP BY spotter_output.aircraft_name 
4090
				ORDER BY aircraft_icao_count DESC";
4091
4092
		$sth = $this->db->prepare($query);
4093
		$sth->execute(array(':airline_icao' => $airline_icao));
4094
4095
		$ircraft_array = array();
4096
		$temp_array = array();
4097
4098
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4099
		{
4100
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4101
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4102
			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4103
4104
			$aircraft_array[] = $temp_array;
4105
		}
4106
		return $aircraft_array;
4107
	}
4108
4109
4110
	/**
@@ 4191-4215 (lines=25) @@
4188
	* @return Array the aircraft list
4189
	*
4190
	*/
4191
	public function countAllAircraftTypesByAirport($airport_icao)
4192
	{
4193
		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4194
4195
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4196
				FROM spotter_output
4197
				WHERE spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
4198
				GROUP BY spotter_output.aircraft_name 
4199
				ORDER BY aircraft_icao_count DESC";
4200
 
4201
		$sth = $this->db->prepare($query);
4202
		$sth->execute(array(':airport_icao' => $airport_icao));
4203
4204
		$aircraft_array = array();
4205
		$temp_array = array();
4206
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4207
		{
4208
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4209
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4210
			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4211
4212
			$aircraft_array[] = $temp_array;
4213
		}
4214
		return $aircraft_array;
4215
	}
4216
4217
4218
	/**
@@ 4305-4332 (lines=28) @@
4302
	* @return Array the aircraft list
4303
	*
4304
	*/
4305
	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer)
4306
	{
4307
		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4308
4309
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4310
                    FROM spotter_output
4311
                    WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
4312
                    GROUP BY spotter_output.aircraft_name 
4313
					ORDER BY aircraft_icao_count DESC";
4314
 
4315
		
4316
		$sth = $this->db->prepare($query);
4317
		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4318
      
4319
        $aircraft_array = array();
4320
		$temp_array = array();
4321
        
4322
        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4323
		{
4324
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4325
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4326
            $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4327
          
4328
            $aircraft_array[] = $temp_array;
4329
		}
4330
4331
		return $aircraft_array;
4332
	}
4333
	
4334
	
4335
	/**
@@ 4537-4562 (lines=26) @@
4534
	* @return Array the aircraft list
4535
	*
4536
	*/
4537
	public function countAllAircraftTypesByIdent($ident)
4538
	{
4539
		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4540
4541
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4542
				FROM spotter_output
4543
				WHERE spotter_output.ident = :ident 
4544
				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
4545
				ORDER BY aircraft_icao_count DESC";
4546
4547
		$sth = $this->db->prepare($query);
4548
		$sth->execute(array(':ident' => $ident));
4549
      
4550
		$aircraft_array = array();
4551
		$temp_array = array();
4552
4553
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4554
		{
4555
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4556
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4557
			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4558
4559
			$aircraft_array[] = $temp_array;
4560
		}
4561
		return $aircraft_array;
4562
	}
4563
4564
4565
	/**
@@ 4772-4799 (lines=28) @@
4769
	* @return Array the aircraft list
4770
	*
4771
	*/
4772
	public function countAllAircraftTypesByCountry($country)
4773
	{
4774
		$country = filter_var($country,FILTER_SANITIZE_STRING);
4775
4776
		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4777
                    FROM spotter_output
4778
                    WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4779
                    GROUP BY spotter_output.aircraft_name 
4780
					ORDER BY aircraft_icao_count DESC";
4781
 
4782
		
4783
		$sth = $this->db->prepare($query);
4784
		$sth->execute(array(':country' => $country));
4785
      
4786
		$aircraft_array = array();
4787
		$temp_array = array();
4788
        
4789
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4790
		{
4791
			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4792
			$temp_array['aircraft_name'] = $row['aircraft_name'];
4793
			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4794
          
4795
			$aircraft_array[] = $temp_array;
4796
		}
4797
4798
		return $aircraft_array;
4799
	}
4800
4801
4802
	/**