Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 76 |
| SchoolService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
342.00 | |
0.00% |
0 / 76 |
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getSchools | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| getAllDepartmentDetailsBySchoolId | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 28 |
|||
| getAllSchoolsForApi | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 23 |
|||
| getSchoolById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\base\exception\CoreException; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\request\api\GetAllDepartmentsSchoolRequest; | |
| class SchoolService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| // /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; | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getSchools() | |
| { | |
| $sql = "select id,name from v4_school;"; | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * | |
| * @param GetAllDepartmentsSchoolRequest $request | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| * @throws ProfessionalException | |
| * @author renjith-roy | |
| */ | |
| public function getAllDepartmentDetailsBySchoolId(GetAllDepartmentsSchoolRequest $request) | |
| { | |
| $sql = ""; | |
| $request = $this->realEscapeObject($request); | |
| $sql = "SELECT dpt.deptID as id, | |
| dpt.deptName as name, | |
| dpt.deptName as text, | |
| dpt.departmentDesc as description, | |
| dpt.deptShow, | |
| dpt.admissionShow | |
| FROM | |
| department dpt | |
| INNER JOIN | |
| v4_school vs ON vs.id = dpt.school_id WHERE 1=1 "; | |
| if ($request) { | |
| if (is_array($request->schoolId) && sizeof($request->schoolId)>0) | |
| { | |
| $sql .= " AND dpt.school_id IN ('" . (implode("','", $request->schoolId)) . "')"; | |
| } | |
| elseif ($request->schoolId) { | |
| $sql .= " AND dpt.school_id = '$request->schoolId'"; | |
| } | |
| } | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * | |
| * @param GetAllDepartmentsSchoolRequest $request | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| * @throws ProfessionalException | |
| * @author renjith-roy | |
| */ | |
| public function getAllSchoolsForApi(GetAllDepartmentsSchoolRequest $request) | |
| { | |
| $sql = ""; | |
| $request = $this->realEscapeObject($request); | |
| $responseList = []; | |
| $sql = "SELECT | |
| id, | |
| name , | |
| description | |
| FROM | |
| v4_school WHERE 1=1 "; | |
| if ($request) { | |
| if ($request->id) { | |
| $sql .= " AND id = $request->id"; | |
| } else if (!empty($request->ids)) { | |
| $sql .= " AND id in ('" . implode("','", $request->ids) . "')"; | |
| } | |
| } | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * | |
| * @param $schoolId | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| * @throws ProfessionalException | |
| * @author renjith-roy | |
| */ | |
| public function getSchoolById($schoolId) | |
| { | |
| $school = NULL; | |
| $sql = "SELECT id,name, description FROM v4_school WHERE id='$schoolId'"; | |
| try { | |
| $school = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $school; | |
| } | |
| } |