/** * Constructor. * * TODO: get_ship_info call must not be mandatory (for example, if we * only create a new ship objects so it can be made part of * fleet to be added to the database, we don't want to grab * all info about the ship from the db * * @param $ship_id * @return (nothing) */ public function __construct($ship_name) { global $db; $this->db = $db; // load valid shipnames $ships = new ships(); $valid_ship_names = $ships->get_all_ships_name(); // only proceed if the passed ship_name is an allowed shipname if (in_array($ship_name, $valid_ship_names)) { $this->name = $ship_name; $this->get_ship_info($this->name); } }
/** * Grabs all ship names and reformats them to column name format. The * fleet_id parameter is passed such that the correct column can be * constructed. * * @param $fleet_id (0, 1, 2, 3) * @return unknown_type */ private function ship2column($fleet_id) { // 1 - get all ship names $ships = new ships(); $ships_name = $ships->get_all_ships_name(); // 2 - format properly and attach fleet_number foreach ($ships_name as $ship_name) { $ships_out[] = strtolower($ship_name) . "_" . $fleet_id; } return $ships_out; }