Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 77 |
| UniversityService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
342.00 | |
0.00% |
0 / 77 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getUniversities | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| createUniversity | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getUniversityById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getUniversityByName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| updateUniversity | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| deleteUniversity | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getUniversityByBatchId | |
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; | |
| use com\linways\core\ams\dataImporter\request\AddUniversityRequest; | |
| class UniversityService 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; | |
| } | |
| /** | |
| * Get university list | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| public function getUniversities() | |
| { | |
| $universities = NULL; | |
| $sql = "select * from university"; | |
| try { | |
| $universities = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $universities; | |
| } | |
| /** | |
| * Create file location details | |
| * @param University $university | |
| * @throws ProfessionalException | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| */ | |
| public function createUniversity($university) | |
| { | |
| $university = $this->realEscapeObject($university); | |
| $sql = "insert into university ( name, description,considerFailedSubjectCredit, createdBy, createdDate, updatedBy, updatedDate) values (\"$university->name\", \"$university->description\", $university->considerFailedSubCredit, $university->createdBy, UTC_TIMESTAMP(), $university->updatedBy, UTC_TIMESTAMP())"; | |
| try { | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get university details by id | |
| * @param string $id | |
| * @throws ProfessionalException | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| */ | |
| public function getUniversityById($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $university = null; | |
| $sql = "select * from university where id = $id"; | |
| try { | |
| $university = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $university; | |
| } | |
| public function getUniversityByName($name) | |
| { | |
| $id = $this->realEscapeString($name); | |
| $university = null; | |
| $sql = "SELECT id FROM university WHERE name = '$name'"; | |
| try { | |
| $university = $this->executeQueryForObject($sql)->id; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $university; | |
| } | |
| /** | |
| * update university details | |
| * @param University $university | |
| * @throws ProfessionalException | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| */ | |
| public function updateUniversity($university) | |
| { | |
| $university = $this->realEscapeObject($university); | |
| $sql = "update university set name = \"$university->name\", description = \"$university->description\", considerFailedSubjectCredit=$university->considerFailedSubCredit, updatedBy = $university->updatedBy, updatedDate = UTC_TIMESTAMP() where id = $university->id"; | |
| try { | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Delete university | |
| * @param string $id | |
| * @throws ProfessionalException | |
| * @return \com\linways\base\dto\MySqlResult | |
| */ | |
| public function deleteUniversity($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $sql = "delete from university where id = $id"; | |
| try { | |
| return $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get university by batchId | |
| * @param int $batchId | |
| * @throws ProfessionalException | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| */ | |
| public function getUniversityByBatchId($batchId) | |
| { | |
| $batchId = $this->realEscapeString($batchId); | |
| $sql = "select uni.id as universityId, uni.name as universityName, uni.description, considerFailedSubjectCredit, batchID, batchName, patternID, type_name as courseTypeName from university uni inner join batches ba on ba.universityId = uni.id left join batch_course_type bct on bct.id = ba.patternID where batchID = $batchId"; | |
| try { | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| } |