/** * @return bool */ private function updateLogEntries() { foreach ($this->logEntries as $entry) { //look all the subsequent records for related entries //See if there is a record we can join with $nextRecord = $this->fetchNextRecord($entry['user_id'], $entry['device'], $entry['reason'], $entry['finished']); if ($nextRecord) { $this->equipmentLogRepository->update($entry['id'], ['finished' => $nextRecord['finished']]); $this->equipmentLogRepository->delete($nextRecord['id']); //The array is now dirty - re-fetch it and return to restart the check $this->logEntries = $this->equipmentLogRepository->getUnbilledRecords(); return true; } } return false; }