classNameNormalizer = $classNameNormalizer; $this->detailFactory = $detailFactory; } /** * @param string $modelName * @param array $beforeData * @param array $afterData * @return LogEntry\LogDetail[] */ public function build(string $modelName, array $beforeData, array $afterData): array { $detailList = []; $allDataKeys = array_keys(array_merge($beforeData, $afterData)); foreach ($allDataKeys as $dataKey) { $oldValue = $beforeData[$dataKey] ?? null; $newValue = $afterData[$dataKey] ?? null; if ($oldValue != $newValue) { $detailList[] = $this->detailFactory->create(['data' => [ LogEntry\LogDetail::MODEL => $this->classNameNormalizer->execute($modelName), LogEntry\LogDetail::NAME => $dataKey, LogEntry\LogDetail::OLD_VALUE => $oldValue, LogEntry\LogDetail::NEW_VALUE => $newValue, ]]); } } return $detailList; } }