Code Coverage  | 
      ||||||||||
Classes and Traits  | 
       Functions and Methods  | 
       Lines  | 
      ||||||||
| Total |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 6  | 
       CRAP |         | 
       0.00%  | 
       0 / 36  | 
      
| MealSessionService |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 6  | 
       110.00 |         | 
       0.00%  | 
       0 / 36  | 
      
| __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  | 
      |||
| getSessionDetails |         | 
       0.00%  | 
       0 / 1  | 
       6.00 |         | 
       0.00%  | 
       0 / 9  | 
      |||
| setSessionTime |         | 
       0.00%  | 
       0 / 1  | 
       6.00 |         | 
       0.00%  | 
       0 / 10  | 
      |||
| getOrderTimeByCode |         | 
       0.00%  | 
       0 / 1  | 
       6.00 |         | 
       0.00%  | 
       0 / 10  | 
      |||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\dto\MealSession; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| class MealSessionService 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; | |
| } | |
| /** | |
| * To get the assined session time to order | |
| * @throws ProfessionalException | |
| * @return MealSession ObjectList | |
| */ | |
| public function getSessionDetails() | |
| { | |
| $sql = "select orderTime,code from meal_session"; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| /** | |
| * To set the session time to order | |
| * @param \DateTime $time | |
| * @param string $sessionCode | |
| * @throws ProfessionalException | |
| */ | |
| public function setSessionTime($time,$code) | |
| { | |
| $time=$this->realEscapeString($time); | |
| $code = $this->realEscapeString($code); | |
| $sql = "update meal_session set orderTime = '$time' where code='$code'"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * To get order time of a session | |
| * @param string $code | |
| * @throws ProfessionalException | |
| * @return MealSession Object | |
| */ | |
| public function getOrderTimeByCode($code) | |
| { | |
| $code = $this->realEscapeString($code); | |
| $sql = "select orderTime from meal_session where code= '$code'"; | |
| try { | |
| $result = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| } |