'whmcs:sync-clients', 'forceSync' => true], ['command' => 'whmcs:sync-products', 'forceSync' => false], ['command' => 'whmcs:sync-orders', 'forceSync' => true], ['command' => 'whmcs:sync-order-items', 'forceSync' => false], ['command' => 'whmcs:sync-invoices', 'forceSync' => true], ['command' => 'whmcs:sync-services', 'forceSync' => false], ['command' => 'whmcs:sync-domains', 'forceSync' => false], ]; public function handle(SyncReport $report): int { $report->beginBatch(); if ($this->option('with-domain-sync')) { $exitCode = $this->runStep('domain:sync', []); if ($exitCode !== self::SUCCESS) { return $exitCode; } } else { $this->warn('Skipping domain:sync — whmcs:sync-domains expects it to already be up to date. Pass --with-domain-sync to run it here.'); } foreach (self::STEPS as $step) { $arguments = $step['forceSync'] ? ['--sync' => true] : []; if ($this->option('missing-only') && $step['command'] !== 'whmcs:sync-products') { $arguments['--missing-only'] = true; } $exitCode = $this->runStep($step['command'], $arguments); if ($exitCode !== self::SUCCESS) { $report->finishBatch($this); return $exitCode; } } $this->info('whmcs:sync-all completed successfully.'); $report->finishBatch($this); return self::SUCCESS; } private function runStep(string $command, array $arguments): int { $this->newLine(); $this->info("==> {$command}"); $exitCode = $this->call($command, $arguments); if ($exitCode !== self::SUCCESS) { $this->error("{$command} failed with exit code {$exitCode}; stopping."); } return $exitCode; } }