From ed02e3522e320f53bb342d6e61ee8dde011a69d0 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 7 Nov 2018 11:57:08 +0100 Subject: [PATCH] code cleanup --- core/ormstopwatch.class.inc.php | 38 ++++++++++++++----- .../main.itop-sla-computation.php | 24 ++++++++---- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 751302e49..8a8616831 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -1,5 +1,5 @@ Get('working_time_computing'); @@ -267,11 +281,6 @@ class ormStopWatch { $sWorkingTimeComputer = class_exists('SLAComputation') ? 'SLAComputation' : 'DefaultWorkingTimeComputer'; } - $aCallSpec = array($sWorkingTimeComputer, '__construct'); - if (!is_callable($aCallSpec)) - { - //throw new CoreException("Pas de constructeur pour $sWorkingTimeComputer!"); - } $oComputer = new $sWorkingTimeComputer(); $aCallSpec = array($oComputer, 'GetDeadline'); if (!is_callable($aCallSpec)) @@ -285,6 +294,15 @@ class ormStopWatch return $iRet; } + /** + * @param $oObject + * @param $oAttDef + * @param $iStartTime + * @param $iEndTime + * + * @return mixed + * @throws \CoreException + */ protected function ComputeDuration($oObject, $oAttDef, $iStartTime, $iEndTime) { $sWorkingTimeComputer = $oAttDef->Get('working_time_computing'); @@ -398,7 +416,7 @@ class ormStopWatch $aThresholdData['triggered'] = false; $aThresholdData['overrun'] = null; } - else + // else { // The new threshold is in the past // Note: the overrun can be wrong, but the correct algorithm to compute @@ -558,7 +576,7 @@ class CheckStopWatchThresholds implements iBackgroundProcess CMDBObject::SetTrackInfo("Automatic - threshold triggered"); $oMyChange = CMDBObject::GetCurrentChange(); - $oObj->DBUpdateTracked($oMyChange, true /*skip security*/); + $oObj->DBUpdateTracked($oMyChange); } // Activate any existing trigger diff --git a/datamodels/2.x/itop-sla-computation/main.itop-sla-computation.php b/datamodels/2.x/itop-sla-computation/main.itop-sla-computation.php index 83d969df3..1f0893705 100755 --- a/datamodels/2.x/itop-sla-computation/main.itop-sla-computation.php +++ b/datamodels/2.x/itop-sla-computation/main.itop-sla-computation.php @@ -1,5 +1,5 @@ Init(); @@ -70,10 +74,13 @@ class SLAComputation implements iWorkingTimeComputer /** * Get the date/time corresponding to a given delay in the future from the present * considering only the valid (open) hours for a specified object - * @param $oObject DBObject The object for which to compute the deadline + * + * @param $oObject Ticket The object for which to compute the deadline * @param $iDuration integer The duration (in seconds) in the future * @param $oStartDate DateTime The starting point for the computation + * * @return DateTime The date/time for the deadline + * @throws \Exception */ public function GetDeadline($oObject, $iDuration, DateTime $oStartDate) { @@ -90,11 +97,14 @@ class SLAComputation implements iWorkingTimeComputer } /** - * Get duration (considering only open hours) elapsed bewteen two given DateTimes - * @param $oObject DBObject The object for which to compute the duration + * Get duration (considering only open hours) elapsed between two given DateTimes + * + * @param $oObject Ticket The object for which to compute the duration * @param $oStartDate DateTime The starting point for the computation (default = now) * @param $oEndDate DateTime The ending point for the computation (default = now) + * * @return integer The duration (number of seconds) of open hours elapsed between the two dates + * @throws \Exception */ public function GetOpenDuration($oObject, DateTime $oStartDate, DateTime $oEndDate) { @@ -149,7 +159,7 @@ class SLAComputationAddOnAPI } /** - * Get duration (considering only open hours) elapsed bewteen two given DateTimes + * Get duration (considering only open hours) elapsed between two given DateTimes * @param $oTicket Ticket The ticket for which to compute the duration * @param $oStartDate DateTime The starting point for the computation (default = now) * @param $oEndDate DateTime The ending point for the computation (default = now)