fetcher->fetchAll(); $this->repository->synchronize($stores); $this->logWriter->write([ 'direction' => 'pull', 'operation' => 'store_sync', 'entity_type' => 'store', 'status' => 'success', 'response_payload' => ['store_count' => count($stores)], 'duration_ms' => (int)round((microtime(true) - $started) * 1000), ]); return count($stores); } catch (\Throwable $exception) { $code = $exception instanceof ApiException ? $exception->getErrorCode() : (string)$exception->getCode(); $response = $exception instanceof ApiException ? $exception->getResponse() : []; $this->logWriter->write([ 'direction' => 'pull', 'operation' => 'store_sync', 'entity_type' => 'store', 'status' => 'failed', 'error_code' => $code, 'error_message' => $exception->getMessage(), 'response_payload' => $response, 'duration_ms' => (int)round((microtime(true) - $started) * 1000), ]); throw $exception; } } }