🎨 PHP code formatting

This commit is contained in:
Pierre Goiffon
2019-01-16 17:25:48 +01:00
parent 8c642827f3
commit 885f4a64a4

View File

@@ -70,7 +70,7 @@ class NotifyOnExpiration implements iScheduledProcess
} }
$oNow = new DateTime(); $oNow = new DateTime();
$iNextPos = false; $iNextPos = false;
for ($iDay = $oNow->format('N') ; $iDay <= 7 ; $iDay++) for ($iDay = $oNow->format('N'); $iDay <= 7; $iDay++)
{ {
$iNextPos = array_search($iDay, $aDays); $iNextPos = array_search($iDay, $aDays);
if ($iNextPos !== false) if ($iNextPos !== false)
@@ -101,8 +101,9 @@ class NotifyOnExpiration implements iScheduledProcess
$oRet = clone $oNow; $oRet = clone $oNow;
$oRet->modify('+'.$iMove.' days'); $oRet->modify('+'.$iMove.' days');
} }
$oRet->setTime((int)$aMatches[1], (int) $aMatches[2]); $oRet->setTime((int)$aMatches[1], (int)$aMatches[2]);
} }
return $oRet; return $oRet;
} }
@@ -123,7 +124,7 @@ class NotifyOnExpiration implements iScheduledProcess
$this->Trace('Processing '.$oRulesSet->Count().' active expiration rules...'); $this->Trace('Processing '.$oRulesSet->Count().' active expiration rules...');
$iTotalProcessedObjectsCount = 0; $iTotalProcessedObjectsCount = 0;
while($oRule = $oRulesSet->Fetch()) while ($oRule = $oRulesSet->Fetch())
{ {
$iRuleProcessedObjectsCount = 0; $iRuleProcessedObjectsCount = 0;
$this->Trace('Processing rule "'.$oRule->Get('friendlyname').'" (#'.$oRule->GetKey().')...'); $this->Trace('Processing rule "'.$oRule->Get('friendlyname').'" (#'.$oRule->GetKey().')...');
@@ -187,14 +188,14 @@ class NotifyOnExpiration implements iScheduledProcess
$this->Trace('Stopped because time limit exceeded!'); $this->Trace('Stopped because time limit exceeded!');
} }
} }
catch(Exception $e) catch (Exception $e)
{ {
$this->Trace('Skipping rule as there was an exception! ('.$e->getMessage().')'); $this->Trace('Skipping rule as there was an exception! ('.$e->getMessage().')');
} }
} }
// Report // Report
if($aReport['reached_deadline'] === 0) if ($aReport['reached_deadline'] === 0)
{ {
return 'No object to process'; return 'No object to process';
} }
@@ -203,17 +204,18 @@ class NotifyOnExpiration implements iScheduledProcess
$iClosedCount = count($aReport['triggered']); $iClosedCount = count($aReport['triggered']);
$iNotClosedCount = count($aReport['not_triggered']); $iNotClosedCount = count($aReport['not_triggered']);
$sReport = $aReport['reached_deadline'] . " objects reached triggering date"; $sReport = $aReport['reached_deadline']." objects reached triggering date";
$sReport .= " - ".$iClosedCount." were triggered"; $sReport .= " - ".$iClosedCount." were triggered";
if($iClosedCount > 0) if ($iClosedCount > 0)
{ {
$sReport .= " (".implode(", ", $aReport['triggered']).")"; $sReport .= " (".implode(", ", $aReport['triggered']).")";
} }
$sReport .= " - ".$iNotClosedCount." were not triggered"; $sReport .= " - ".$iNotClosedCount." were not triggered";
if($iNotClosedCount > 0) if ($iNotClosedCount > 0)
{ {
$sReport .= " (".implode(", ", $aReport['not_triggered']).")"; $sReport .= " (".implode(", ", $aReport['not_triggered']).")";
} }
return $sReport; return $sReport;
} }
} }
@@ -227,7 +229,15 @@ class NotifyOnExpiration implements iScheduledProcess
*/ */
public function InterpretWeekDays() public function InterpretWeekDays()
{ {
static $aWEEKDAYTON = array('monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7); static $aWEEKDAYTON = array(
'monday' => 1,
'tuesday' => 2,
'wednesday' => 3,
'thursday' => 4,
'friday' => 5,
'saturday' => 6,
'sunday' => 7,
);
$aDays = array(); $aDays = array();
$sWeekDays = MetaModel::GetConfig()->GetModuleSetting(static::MODULE_CODE, static::KEY_MODULE_SETTING_WEEKDAYS, $sWeekDays = MetaModel::GetConfig()->GetModuleSetting(static::MODULE_CODE, static::KEY_MODULE_SETTING_WEEKDAYS,
static::DEFAULT_MODULE_SETTING_WEEKDAYS); static::DEFAULT_MODULE_SETTING_WEEKDAYS);
@@ -253,6 +263,7 @@ class NotifyOnExpiration implements iScheduledProcess
} }
$aDays = array_unique($aDays); $aDays = array_unique($aDays);
sort($aDays); sort($aDays);
return $aDays; return $aDays;
} }