sType = $sType; $this->sOperation = $sOperation; $this->sArguments = @iconv(mb_detect_encoding($sArguments, mb_detect_order(), true), 'UTF-8', $sArguments); $this->fStartTime = $fStartTime; $this->fStopTime = $fStopTime; $this->sExtension = $sExtension; $this->iInitialMemory = $iInitialMemory; $this->iCurrentMemory = $iCurrentMemory; $this->iPeakMemory = $iPeakMemory; $this->aData = $aData; $this->sDuration = sprintf('%01.3f', $fStopTime - $fStartTime); } /** * Return the CSV Header * * @return string */ public static function GetCSVHeader() { return 'Type,Operation,Arguments,StartTime,StopTime,Duration,Extension,InitialMemory,CurrentMemory,PeakMemory'; } /** * Return the CSV line for the values * * @return string */ public function GetCSV() { $sType = $this->RemoveQuotes($this->sType); $sOperation = $this->RemoveQuotes($this->sOperation); $sArguments = $this->RemoveQuotes($this->sArguments); $sExtension = $this->RemoveQuotes($this->sExtension); return "\"$sType\",\"$sOperation\",\"$sArguments\",$this->fStartTime,$this->fStopTime,$this->sDuration,\"$sExtension\",$this->iInitialMemory,$this->iCurrentMemory,$this->iPeakMemory"; } private function RemoveQuotes(string $sEntry): string { return str_replace('"', "'", $sEntry); } /** * @param \Combodo\iTop\Core\Kpi\KpiLogData $oOther * * @return float */ public function Compare(KpiLogData $oOther): float { if ($oOther->fStartTime > $this->fStartTime) { return -1; } return 1; } public function Contains(KpiLogData $oOther): bool { if ($oOther->fStartTime < $this->fStartTime) { return false; } if ($oOther->fStartTime > $this->fStopTime) { return false; } return true; } public function __toString() { return "$this->sType:$this->sOperation:$this->sArguments"; } public function GetUUID(): string { return sha1($this->__toString()); } }