do { if (empty($_GET['type'])) { $validate = false; $response = BaseClass::createResponse(0, "Invalid Request"); break; } $type = strtoupper($_GET['type']); /* * Types (Whenever new types are defined update this comment too) * AD => Add Details */ switch ($type) { case 'AD': if (empty($_POST['location']) || !isset($_FILES['image'])) { $validate = false; $response = BaseClass::createResponse(0, "Invalid Request"); } break; } } while (0); //Business Logic if ($validate) { $bharat = new SaveBharat(); switch ($type) { case 'AD': $bharat->location = $_POST['location']; $bharat->image = $_FILES['image']; $response = $bharat->saveDetails(); break; } }