private static function gymsForResult($result) { $gyms = array(); if ($result && mysqli_num_rows($result) > 0) { foreach ($result as $row) { $gym = new Gym($row); array_push($gyms, $gym->serialize()); } } return $gyms; }