Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 61 |
| MealMenuService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
210.00 | |
0.00% |
0 / 61 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| createMealMenu | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| updateMealMenu | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| deleteMealMenu | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getFoodItemById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getFoodItems | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\service\BaseService; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\dto\MealMenu; | |
| use com\linways\core\ams\professional\dto\AssignMeal; | |
| class MealMenuService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| {} | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| {} | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self(); | |
| return self::$_instance; | |
| } | |
| /** | |
| * Create meal menu item | |
| * @param MealMenu $menu | |
| * @throws ProfessionalException | |
| */ | |
| public function createMealMenu($menu) | |
| { | |
| $menu->itemCode= $this->realEscapeString($menu->itemCode); | |
| $menu->itemName = $this->realEscapeString($menu->itemName); | |
| $menu->description = $this->realEscapeString($menu->description); | |
| $menu->createdBy = $this->realEscapeString($menu->createdBy); | |
| $menu->updatedBy = $this->realEscapeString($menu->updatedBy); | |
| $sql = "insert into meal_menu (itemCode,itemName,description,createdBy,createdDate,updatedBy,updatedDate) values('$menu->itemCode','$menu->itemName','$menu->description','$menu->createdBy',utc_timestamp(),'$menu->updatedBy',utc_timestamp())"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * To update meal menu item | |
| * @param MealMenu $menu | |
| * @throws ProfessionalException | |
| */ | |
| public function updateMealMenu($menu) | |
| { | |
| $menu->itemCode= $this->realEscapeString($menu->itemCode); | |
| $menu->itemName = $this->realEscapeString($menu->itemName); | |
| $menu->description = $this->realEscapeString($menu->description); | |
| $menu->createdBy = $this->realEscapeString($menu->createdBy); | |
| $menu->updatedBy = $this->realEscapeString($menu->updatedBy); | |
| $sql = "update meal_menu set itemCode = '$menu->itemCode', itemName= '$menu->itemName', description='$menu->description', updatedBy ='$menu->updatedBy', updatedDate=utc_timestamp() where id='$menu->itemId'"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * To delete a meal menu item | |
| * @param string $itemName | |
| * @throws ProfessionalException | |
| */ | |
| public function deleteMealMenu($itemId) | |
| { | |
| $itemId= $this->realEscapeString($itemId); | |
| $sql = "delete from meal_menu where id='$itemId'"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get details of a food item | |
| * @param int $itemId | |
| * @throws ProfessionalException | |
| * @return MealMenu object | |
| */ | |
| public function getFoodItemById($itemId) | |
| { | |
| $itemId=$this->realEscapeString($itemId); | |
| $sql = "select itemCode, itemName, description from meal_menu where id ='$itemId'"; | |
| try { | |
| $itemDetails = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $itemDetails; | |
| } | |
| /** | |
| * Get all the food items | |
| * @throws ProfessionalException | |
| * @return MealMenu object[] | |
| */ | |
| public function getFoodItems() | |
| { | |
| $sql = "select id,itemCode, itemName from meal_menu"; | |
| try { | |
| $itemList = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $itemList; | |
| } | |
| } | |