Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 46
ExamRegistrationFeePaymentService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 4
272.00
0.00% covered (danger)
0.00%
0 / 46
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 __clone
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 getInstance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 5
 updateStudentAssessmentRegistraionFeeStatus
0.00% covered (danger)
0.00%
0 / 1
156.00
0.00% covered (danger)
0.00%
0 / 37
<?php 
    namespace com\linways\core\ams\professional\service\examcontroller;
    use com\linways\core\ams\professional\exception\ProfessionalException;
    use com\linways\core\ams\professional\service\BaseService;
    use com\linways\core\ams\professional\constant\examcontroller\ExamRegistrationFeePaymentConstants;
    class ExamRegistrationFeePaymentService 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;
        }
        /**
         * @param Object $request
         * @return Object|null
         * @throws ProfessionalException
         * @author Krishnajith V
         */
        public function updateStudentAssessmentRegistraionFeeStatus($request) {
            $request = $this->realEscapeObject($request);
            $sql = null;
            $studentId = $request->studentId;
            $assessmentIds = $request->assessmentId;
            $updatedBy = $GLOBALS['userId'];
            $paymentStatus = null;
            if($request->paymentStatus == "SUCCESS" || $request->paymentStatus == "PAID" ){
                $paymentStatus = ExamRegistrationFeePaymentConstants::PAID;
            }
            elseif($request->paymentStatus == "UNPAID" || $request->paymentStatus == "UNSUCCESS"){
                $paymentStatus = ExamRegistrationFeePaymentConstants::UNPAID;
            }
            elseif($request->paymentStatus == "PENDING"){
                $paymentStatus = ExamRegistrationFeePaymentConstants::PENDING;
            }
            elseif($request->paymentStatus == "ABORT"){
                $paymentStatus = ExamRegistrationFeePaymentConstants::ABORT;
            }
            if(empty($studentId) || empty($assessmentIds) || empty($paymentStatus) ){
                throw new ProfessionalException(ProfessionalException::EMPTY_PAYMENT_REQUEST_INFO,"Invailed Payment Request");
            }
            foreach($assessmentIds as $assessmentId){
                try {
                    $sql = "UPDATE 
                                ec_student_assessment_registration 
                            SET 
                                properties = JSON_SET(properties, '$.paymentStatus', $paymentStatus
                                updated_by='$updatedBy
                            WHERE 
                                am_assessment_id = '$assessmentId' AND student_id = '$studentId',";
                    $this->executeQuery($sql);
                } catch (\Exception $e) {
                    throw new ProfessionalException($e->getCode(), $e->getMessage());
                }
                
            }
            return true;
        }
       
    }