Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 79 |
AdmissionQuotaService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
342.00 | |
0.00% |
0 / 79 |
__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 |
|||
getAllAdmissionQuotas | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getQuotaIdByName | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 15 |
|||
getQuotaNameById | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
insertAdmissionQuota | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
updateAdmissionQuota | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
deleteAdmissionQuota | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\base\util\RequestUtil; | |
use com\linways\core\ams\professional\dto\AdmissionConstants; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
class AdmissionQuotaService 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; | |
} | |
/** | |
* Method to get all admission quotas | |
* @param NULL | |
* @throws ProfessionalException | |
* @return list of admission quotas | |
*/ | |
public function getAllAdmissionQuotas(){ | |
$sql = ""; | |
$response = ""; | |
$sql = "SELECT quotaID as id, quotaName as name, quotaDesc as description FROM admission_quotas"; | |
try{ | |
$response = $this->executeQueryForList($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* | |
* @param [string] $name | |
* @return int|NULL | |
*/ | |
public function getQuotaIdByName($name){ | |
$sql = ""; | |
$response = ""; | |
$id = null; | |
$name = $this->realEscapeString($name); | |
$sql = "SELECT quotaID as id FROM admission_quotas WHERE quotaName = '$name'"; | |
try{ | |
$response = $this->executeQueryForObject($sql); | |
if(!empty($response->id)){ | |
$id = $response->id; | |
} | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $id; | |
} | |
/** | |
* | |
* | |
* @param [int] $id | |
* @return string|NULL | |
*/ | |
public function getQuotaNameById($id){ | |
$sql = ""; | |
$response = ""; | |
$id = $this->realEscapeString($id); | |
$sql = "SELECT quotaName as name FROM admission_quotas WHERE quotaID = $id"; | |
try{ | |
$response = $this->executeQueryForObject($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
if(!empty($response->name)){ | |
return $response->name; | |
} | |
return NULL; | |
} | |
/** | |
* | |
* @param unknown $nationality | |
* @throws ProfessionalException | |
* @return unknown | |
*/ | |
public function insertAdmissionQuota($quota) | |
{ | |
$quota=$this->realEscapeObject($quota); | |
$query = "insert into admission_quotas (quotaName, quotaDesc) values ('$quota->quotaName', '$quota->quotaDesc')"; | |
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 updateAdmissionQuota($quota) | |
{ | |
$quota=$this->realEscapeObject($quota); | |
$query = "update admission_quotas set quotaName='$quota->quotaName', quotaDesc='$quota->quotaDesc' where quotaID='$quota->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 deleteAdmissionQuota($id) | |
{ | |
$id=$this->realEscapeString($id); | |
$query = "delete from admission_quotas where quotaID='$id'"; | |
try{ | |
$this->executeQuery($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return "success"; | |
} | |
} |