Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 86 |
ReservationStudentsService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
380.00 | |
0.00% |
0 / 86 |
__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 |
|||
getAllReservations | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
insertReservation | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
updateReservation | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
deleteReservation | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getReservationById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getAllReservationsList | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
getStudentReservationsList | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
class ReservationStudentsService extends BaseService | |
{ | |
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; | |
} | |
/** | |
* show all reservations | |
* | |
* @author Aswin | |
* @throws ProfessionalException | |
* @return unknown | |
*/ | |
public function getAllReservations() | |
{ | |
$query = "SELECT * FROM reservation_students ORDER BY reservationName ASC"; | |
try { | |
$response = $this->executeQueryForList($query); | |
if (! $response) { | |
throw new ProfessionalException(ProfessionalException::ARRAY_EMPTY, "No reservations found"); | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* Insert reservation | |
* @author Aswin | |
* @param string $reservationName | |
* @param string $reservationCode | |
* @param string $reservationDescription | |
* @throws ProfessionalException | |
* @return unknown | |
*/ | |
public function insertReservation($reservationName, $reservationCode, $reservationDescription) | |
{ | |
$reservationName=$this->realEscapeString($reservationName); | |
$reservationCode=$this->realEscapeString($reservationCode); | |
$reservationDescription=$this->realEscapeString($reservationDescription); | |
$query = "insert into reservation_students (reservationName,reservationCode,reservationDesc) values ('$reservationName','$reservationCode','$reservationDescription')"; | |
try{ | |
$response=$this->executeQueryForObject($query,true); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* Update reservation | |
* @author Aswin | |
* @param string $reservationID | |
* @param string $reservationName | |
* @param string $reservationCode | |
* @param string $reservationDescription | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function updateReservation($reservationID,$reservationName, $reservationCode, $reservationDescription) | |
{ | |
$reservationName=$this->realEscapeString($reservationName); | |
$reservationCode=$this->realEscapeString($reservationCode); | |
$reservationDescription=$this->realEscapeString($reservationDescription); | |
$reservationID=$this->realEscapeString($reservationID); | |
$query = "update reservation_students set reservationName='$reservationName',reservationCode='$reservationCode',reservationDesc='$reservationDescription' where reservationID='$reservationID'"; | |
try{ | |
$response=$this->executeQuery($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return "success"; | |
} | |
/** | |
* Delete reservatiom | |
* @author Aswin | |
* @param string $reservationID | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function deleteReservation($reservationID) | |
{ | |
$reservationID=$this->realEscapeString($reservationID); | |
$query = "delete from reservation_students where reservationID='$reservationID'"; | |
try{ | |
$response=$this->executeQuery($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return "success"; | |
} | |
/** | |
* get reservation by id | |
* @author Aswin | |
* @param unknown $reservationID | |
* @throws ProfessionalException | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
*/ | |
public function getReservationById($reservationID) | |
{ | |
$reservationID = $this->realEscapeString($reservationID); | |
$query = "select * from reservation_students where reservationID = '$reservationID'"; | |
try{ | |
$response=$this->executeQueryForObject($query); | |
return $response; | |
}catch (\Exception $e) | |
{ | |
throw new ProfessionalException(ProfessionalException::QUERY_EXECUTION_FAILED,"No reservation found for this id"); | |
} | |
} | |
public function getAllReservationsList() | |
{ | |
$query = "SELECT * FROM reservation_students ORDER BY reservationName ASC"; | |
try { | |
$response = $this->executeQueryForList($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
public function getStudentReservationsList() | |
{ | |
$query = "SELECT reservID as reservationID,reservName as reservationName FROM student_reservation ORDER BY reservName ASC"; | |
try { | |
$response = $this->executeQueryForList($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
} | |