Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 27 |
ResourceService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
72.00 | |
0.00% |
0 / 27 |
__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 |
|||
createNewResource | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
confirmResourceById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
<?php | |
namespace com\linways\core\ams\professional\service\resource; | |
use com\linways\base\util\SecurityUtils; | |
use com\linways\core\ams\professional\service\BaseService; | |
class ResourceService 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; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param [type] $resource | |
* @return void | |
*/ | |
public function createNewResource($resource){ | |
$resource = $this->realEscapeObject($resource); | |
$sql = ""; | |
$resource->id = SecurityUtils::getRandomString(); | |
$sql = "INSERT INTO `lin_resource` (`id`,`path`, `context`, `is_confirmed`, `created_by`, `updated_by`, `created_date`, `updated_date`) VALUES ('$resource->id','$resource->path', '$resource->context', '$resource->isConfirmed', '$resource->createdBy', '$resource->updatedBy', UTC_TIMESTAMP(), UTC_TIMESTAMP());"; | |
try{ | |
$this->executeQuery($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $resource; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param [type] $id | |
* @return void | |
*/ | |
public function confirmResourceById($id){ | |
$id = $this->realEscapeString($id); | |
$sql = "UPDATE `lin_resource` SET `is_confirmed`='1' WHERE `id`='$id'"; | |
try{ | |
$this->executeQuery($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $id; | |
} | |
} |