Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 72 |
| NationalityService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
306.00 | |
0.00% |
0 / 72 |
| __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 |
|||
| getAllNationalities | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
| fetchAllNationalities | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| insertNationality | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| updateNationality | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| deleteNationality | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getNationalityById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use phpDocumentor\Reflection\Types\Integer; | |
| class NationalityService 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 gadheyan | |
| * @throws ProfessionalException | |
| * @return unknown | |
| */ | |
| public function getAllNationalities() | |
| { | |
| $query = "select id, nationalityName as name from nationality"; | |
| try { | |
| $responseList = $this->executeQueryForList($query); | |
| if (empty($responseList)) { | |
| throw new ProfessionalException(ProfessionalException::ARRAY_EMPTY, "No Records Found!"); | |
| } | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $responseList; | |
| } | |
| /** | |
| * show all nationalities | |
| * | |
| * @author diyana | |
| * @throws ProfessionalException | |
| * @return unknown | |
| */ | |
| public function fetchAllNationalities() | |
| { | |
| $query = "select id, nationalityName as name from nationality"; | |
| try { | |
| $responseList = $this->executeQueryForList($query); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $responseList; | |
| } | |
| /** | |
| * | |
| * @param unknown $nationality | |
| * @throws ProfessionalException | |
| * @return unknown | |
| */ | |
| public function insertNationality($nationality) | |
| { | |
| $nationality=$this->realEscapeObject($nationality); | |
| $query = "insert into nationality (nationalityName) values ('$nationality->name')"; | |
| try{ | |
| $response=$this->executeQueryForObject($query,true); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $response; | |
| } | |
| /** | |
| * | |
| * @param $nationality | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| public function updateNationality($nationality) | |
| { | |
| $nationality=$this->realEscapeObject($nationality); | |
| $query = "update nationality set nationalityName='$nationality->name' where id='$nationality->id'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return "success"; | |
| } | |
| /** | |
| * | |
| * @param integer $id | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| public function deleteNationality($id) | |
| { | |
| $id=$this->realEscapeString($id); | |
| $query = "delete from nationality where id='$id'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return "success"; | |
| } | |
| /** | |
| * | |
| * @param integer $id | |
| * @throws ProfessionalException | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| */ | |
| public function getNationalityById($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $query = "select id, nationalityName as name from nationality where id = '$id'"; | |
| try{ | |
| $response=$this->executeQueryForObject($query); | |
| return $response; | |
| }catch (\Exception $e) | |
| { | |
| throw new ProfessionalException(ProfessionalException::QUERY_EXECUTION_FAILED,"No Record found for this id"); | |
| } | |
| } | |
| } | |