Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 31 |
MobileLoginService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
90.00 | |
0.00% |
0 / 30 |
__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 / 7 |
|||
getLoginTokenByLoginTokenIdAndUserId | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 19 |
<?php | |
/** | |
* Created by PhpStorm. | |
* User: jithinvijayan | |
* Date: 28/02/18 | |
* Time: 6:59 PM | |
*/ | |
//DEPRECRATED - FOR OLD MOBILE VERSION | |
//DEPRECRATED - FOR OLD MOBILE VERSION | |
namespace com\linways\core\ams\professional\service\mobile; | |
use com\linways\core\ams\professional\exception\mobile\MobileException; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\service\BaseService; | |
use function error_log; | |
use Symfony\Component\Config\Definition\Exception\Exception; | |
class MobileLoginService 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; | |
} | |
/** | |
* returns mobile login token by login token id and user id | |
* @param string $loginTokenId | |
* @param string $userId | |
* @param string $userType | |
* @return nulls|string | |
* @throws MobileException | |
* @throws ProfessionalException | |
* @throws \Exception | |
*/ | |
public function getLoginTokenByLoginTokenIdAndUserId($loginTokenId, $userId, $userType) | |
{ | |
$loginToken = null; | |
$loginTokenId = $this->realEscapeString($loginTokenId); | |
$userType = $this->realEscapeString($userType); | |
$userId = $this->realEscapeString($userId); | |
if (empty($userType)) | |
throw new MobileException("Invalid user type", MobileException::INVALID_USER_TYPE); | |
if (empty($userId)) | |
throw new MobileException("Invalid user id", MobileException::INVALID_USER_ID); | |
if (empty($loginTokenId)) | |
throw new MobileException("Invalid login token id", MobileException::INVALID_LOGIN_TOKEN_ID); | |
$sql = "SELECT token FROM mobile_login_tokens WHERE id = $loginTokenId AND user_id = $userId AND user_type='" . $userType . "'"; | |
try { | |
$loginToken = $this->executeQueryForObject($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getMessage(), $e->getCode()); | |
} | |
return $loginToken->token; | |
} | |
} |