Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 33 |
| AttendanceSmsLogService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
110.00 | |
0.00% |
0 / 33 |
| __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 |
|||
| createLogs | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
| getIdsOfSmsSentStudent | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| class AttendanceSmsLogService 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; | |
| } | |
| public function createLogs($logs){ | |
| $sql = ""; | |
| $logs = $this->realEscapeArray($logs); | |
| $sql .= "INSERT INTO `attendance_sms_log` (`student_id`, `hour`, `status`, `created_date`, `updated_date`) VALUES "; | |
| foreach ($logs as $log) { | |
| $sql .= "('$log->studentId', '$log->hour', '$log->status', NOW(), NOW())"; | |
| } | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * [getIdsOfSmsSentStudent description] | |
| * @return [type] [description] | |
| */ | |
| public function getIdsOfSmsSentStudent(){ | |
| $sql = ""; | |
| $result = []; | |
| $response = []; | |
| $sql = "SELECT student_id as studentId from attendance_sms_log WHERE DATE(created_date) = CURDATE()"; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| foreach ($result as $item) { | |
| $response[] = $item->studentId; | |
| } | |
| return $response; | |
| } | |
| } |