Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 44 |
| BioMetricService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
156.00 | |
0.00% |
0 / 44 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getUserIdByBioMetricCredentials | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 16 |
|||
| createNewBiometricAttendanceUploadRequest | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| updateBiometricAttendanceUploadRequest | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| class BioMetricService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| private $mapper = []; | |
| // /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; | |
| } | |
| public function getUserIdByBioMetricCredentials($userType, $biometricId, $deviceId = 1){ | |
| $biometricId = $this->realEscapeString($biometricId); | |
| $deviceId = $this->realEscapeString($deviceId); | |
| $userType = $this->realEscapeString($userType); | |
| $sql = ""; | |
| $userIdDetails = null; | |
| $sql = "SELECT user_id as userId FROM biometrics_users_mapping_table WHERE biometric_id = '$biometricId' AND device_id = '$deviceId' AND user_type = '$userType'"; | |
| try{ | |
| $userIdDetails = $this->executeQueryForObject($sql); | |
| }catch(\Exception $e){ | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| if(empty($userIdDetails) || empty($userIdDetails->userId)){ | |
| return null; | |
| } | |
| return $userIdDetails->userId; | |
| } | |
| /** | |
| * Undocumented function | |
| * | |
| * @param BiometricAttendanceUploadRequest $attendanceUpload | |
| * @return void | |
| */ | |
| public function createNewBiometricAttendanceUploadRequest($attendanceUpload){ | |
| $attendanceUpload = $this->realEscapeObject($attendanceUpload); | |
| $id = null; | |
| $sql = "INSERT INTO `biometrics_attendance_upload_requests` (`request`, `response`, `request_type`, `status`, `created_date`, `updated_date`) VALUES ('$attendanceUpload->request', '$attendanceUpload->response', '$attendanceUpload->requestType', '$attendanceUpload->status', UTC_TIMESTAMP(), UTC_TIMESTAMP())"; | |
| try{ | |
| $id = $this->executeQueryForObject($sql, true); | |
| }catch(\Exception $e){ | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $id; | |
| } | |
| /** | |
| * | |
| * @param BiometricAttendanceUploadRequest $attendanceUpload | |
| * @return void | |
| */ | |
| public function updateBiometricAttendanceUploadRequest($attendanceUpload){ | |
| $attendanceUpload = $this->realEscapeObject($attendanceUpload); | |
| $sql = ""; | |
| $sql = "UPDATE `biometrics_attendance_upload_requests` SET `response`='$attendanceUpload->response', `status`='$attendanceUpload->status', `updated_date`=UTC_TIMESTAMP() WHERE `id`='$attendanceUpload->id';"; | |
| try{ | |
| $this->executeQuery($sql); | |
| }catch(\Exception $e){ | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $attendanceUpload; | |
| } | |
| } | |