$arrEnityEntry) { if ($strKeyField !== false) { if (!isset($arrEnityEntry[$strKeyField])) { continue; } $strKey = strtolower($arrEnityEntry[$strKeyField]); } $arrEntityData = $this->arrEntityMap[$strType][$strKey] ?? []; $this->arrEntityMap[$strType][$strKey] = array_merge( $arrEntityData, array_intersect_key($arrEnityEntry, array_flip($arrFields)) ); } } public function resetEntity($strType = '') { if (!$strType) { $this->arrEntityMap = []; } else { unset($this->arrEntityMap[$strType]); } return $this; } public function addLogEntry($strMessage, $strKey, $strEntityType = 'product', $intTime = 0, $bolIsError = false, $strDebug = '') { if ($bolIsError) { $this->bolHasErrors = true; } if ($intTime == -1) { $intTime = number_format(($this->microtimeFloat() - $this->thisLastRunTime), 4); } $this->arrEntityMap[$strEntityType]['log'][] = array('key' => $strKey, 'message' => $strMessage, 'time' => time(), 'duration' => $intTime, 'isError' => $bolIsError, 'debug' => $strDebug); if (isset($this->arrEntityMap[$strEntityType][strtolower($strKey)]) && is_array($this->arrEntityMap[$strEntityType][$strKey])) { if ($bolIsError) { $this->arrEntityMap[$strEntityType][strtolower($strKey)]['haserrors'] = true; } } $this->thisLastRunTime = $this->microtimeFloat(); } public function getEntityAndReset($strType) { $arrMap = $this->arrEntityMap[$strType] ?? []; $arrMap['status']['recordcount'] = $this->getRecordCount(); $this->resetRecordCount(); unset($this->arrEntityMap[$strType]); return [$strType => $arrMap]; } function getEntityMap($strKey = '') { return !$strKey ? $this->arrEntityMap : ($this->arrEntityMap[$strKey] ?? []); } public function microtimeFloat() { list($usec, $sec) = explode(" ", microtime()); return ((float) $usec + (float) $sec); } public function getDuration($intStartTime) { return number_format(($this->microtimeFloat() - $intStartTime), 4); } public function increaseRecordCount($intCount) { $this->intRecordCount = $this->intRecordCount + $intCount; } public function resetRecordCount() { $this->intRecordCount = 0; } public function getRecordCount() { return $this->intRecordCount; } public function hasErrors() { return $this->bolHasErrors; } }