From f657b53215fb6f3052f03f019466ea24e9ba6ba2 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Sat, 11 Apr 2026 16:30:00 +0200 Subject: [PATCH] refactor(services): split driver infrastructure out of Services into Support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Services/Integrations/ExchangeRate/ and Services/Pdf/ were both mostly Support-shaped: interfaces, abstract classes, static factories, concrete adapter drivers, DTOs, and exceptions — infrastructure that doesn't carry business logic. They only each had one real DI-injected service mixed in. This commit applies the same Services=DI-business-logic / Support=stateless-plumbing rule we've been using throughout the reorg: **Moved to Support/Integrations/ExchangeRate/** (7 files): ExchangeRateDriver (abstract), ExchangeRateDriverFactory (static), ExchangeRateException, and the four concrete drivers (CurrencyConverter, CurrencyFreak, CurrencyLayer, OpenExchangeRate). These are HTTP adapters over third-party currency APIs — same shape as the Hashids library wrapper classes already in Support. **Moved to Support/Pdf/** (6 files, merging with existing Pdf utilities): PdfDriver (interface), PdfDriverFactory (static), PdfService (static facade), GotenbergPdfDriver, GotenbergPdfResponse (DTO), ResponseStream (interface). The Support/Pdf/ dir now contains the full PDF rendering subsystem — drivers + sanitizer + template/image utilities. **Promoted to Services/ root** (the real DI services): ExchangeRateProviderService (CRUD for ExchangeRateProvider model) and FontService (font package install/download orchestration). Both are proper DI services — instance methods, model writes, HTTP side effects. Services/Integrations/ and Services/Pdf/ are now empty and deleted. Services/ holds only DI-injected classes; Support/ holds all the plumbing. 17 files renamed (git detects 90-99% similarity), 4 consumer files updated (DriverRegistryProvider, PdfServiceProvider, ExchangeRateProviderController, FontController, GeneratesPdfTrait, test). 350 tests pass, Pint clean. --- app/Http/Controllers/Admin/FontController.php | 2 +- .../ExchangeRate/ExchangeRateProviderController.php | 2 +- app/Providers/DriverRegistryProvider.php | 8 ++++---- app/Providers/PdfServiceProvider.php | 2 +- .../ExchangeRate => }/ExchangeRateProviderService.php | 6 +++--- app/Services/{Pdf => }/FontService.php | 2 +- .../Integrations/ExchangeRate/CurrencyConverterDriver.php | 2 +- .../Integrations/ExchangeRate/CurrencyFreakDriver.php | 2 +- .../Integrations/ExchangeRate/CurrencyLayerDriver.php | 2 +- .../Integrations/ExchangeRate/ExchangeRateDriver.php | 2 +- .../ExchangeRate/ExchangeRateDriverFactory.php | 2 +- .../Integrations/ExchangeRate/ExchangeRateException.php | 2 +- .../Integrations/ExchangeRate/OpenExchangeRateDriver.php | 2 +- app/{Services => Support}/Pdf/GotenbergPdfDriver.php | 2 +- app/{Services => Support}/Pdf/GotenbergPdfResponse.php | 2 +- app/{Services => Support}/Pdf/PdfDriver.php | 2 +- app/{Services => Support}/Pdf/PdfDriverFactory.php | 2 +- app/{Services => Support}/Pdf/PdfService.php | 2 +- app/{Services => Support}/Pdf/ResponseStream.php | 2 +- app/Traits/GeneratesPdfTrait.php | 2 +- tests/Unit/ExchangeRateDriverFactoryTest.php | 6 +++--- 21 files changed, 28 insertions(+), 28 deletions(-) rename app/Services/{Integrations/ExchangeRate => }/ExchangeRateProviderService.php (95%) rename app/Services/{Pdf => }/FontService.php (99%) rename app/{Services => Support}/Integrations/ExchangeRate/CurrencyConverterDriver.php (97%) rename app/{Services => Support}/Integrations/ExchangeRate/CurrencyFreakDriver.php (97%) rename app/{Services => Support}/Integrations/ExchangeRate/CurrencyLayerDriver.php (97%) rename app/{Services => Support}/Integrations/ExchangeRate/ExchangeRateDriver.php (94%) rename app/{Services => Support}/Integrations/ExchangeRate/ExchangeRateDriverFactory.php (98%) rename app/{Services => Support}/Integrations/ExchangeRate/ExchangeRateException.php (81%) rename app/{Services => Support}/Integrations/ExchangeRate/OpenExchangeRateDriver.php (96%) rename app/{Services => Support}/Pdf/GotenbergPdfDriver.php (96%) rename app/{Services => Support}/Pdf/GotenbergPdfResponse.php (95%) rename app/{Services => Support}/Pdf/PdfDriver.php (77%) rename app/{Services => Support}/Pdf/PdfDriverFactory.php (92%) rename app/{Services => Support}/Pdf/PdfService.php (88%) rename app/{Services => Support}/Pdf/ResponseStream.php (85%) diff --git a/app/Http/Controllers/Admin/FontController.php b/app/Http/Controllers/Admin/FontController.php index ffbc1f71..1791649b 100644 --- a/app/Http/Controllers/Admin/FontController.php +++ b/app/Http/Controllers/Admin/FontController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; -use App\Services\Pdf\FontService; +use App\Services\FontService; use Illuminate\Http\JsonResponse; class FontController extends Controller diff --git a/app/Http/Controllers/Company/ExchangeRate/ExchangeRateProviderController.php b/app/Http/Controllers/Company/ExchangeRate/ExchangeRateProviderController.php index 436c3e4d..c78f0086 100644 --- a/app/Http/Controllers/Company/ExchangeRate/ExchangeRateProviderController.php +++ b/app/Http/Controllers/Company/ExchangeRate/ExchangeRateProviderController.php @@ -14,7 +14,7 @@ use App\Models\ExchangeRateProvider; use App\Models\Invoice; use App\Models\Payment; use App\Models\Tax; -use App\Services\Integrations\ExchangeRate\ExchangeRateProviderService; +use App\Services\ExchangeRateProviderService; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Arr; diff --git a/app/Providers/DriverRegistryProvider.php b/app/Providers/DriverRegistryProvider.php index dda68f4b..90b12aa4 100644 --- a/app/Providers/DriverRegistryProvider.php +++ b/app/Providers/DriverRegistryProvider.php @@ -2,10 +2,10 @@ namespace App\Providers; -use App\Services\Integrations\ExchangeRate\CurrencyConverterDriver; -use App\Services\Integrations\ExchangeRate\CurrencyFreakDriver; -use App\Services\Integrations\ExchangeRate\CurrencyLayerDriver; -use App\Services\Integrations\ExchangeRate\OpenExchangeRateDriver; +use App\Support\Integrations\ExchangeRate\CurrencyConverterDriver; +use App\Support\Integrations\ExchangeRate\CurrencyFreakDriver; +use App\Support\Integrations\ExchangeRate\CurrencyLayerDriver; +use App\Support\Integrations\ExchangeRate\OpenExchangeRateDriver; use Illuminate\Support\ServiceProvider; use InvoiceShelf\Modules\Registry; diff --git a/app/Providers/PdfServiceProvider.php b/app/Providers/PdfServiceProvider.php index acb852b0..05d075ea 100644 --- a/app/Providers/PdfServiceProvider.php +++ b/app/Providers/PdfServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use App\Services\Pdf\PdfService; +use App\Support\Pdf\PdfService; use Illuminate\Support\ServiceProvider; class PdfServiceProvider extends ServiceProvider diff --git a/app/Services/Integrations/ExchangeRate/ExchangeRateProviderService.php b/app/Services/ExchangeRateProviderService.php similarity index 95% rename from app/Services/Integrations/ExchangeRate/ExchangeRateProviderService.php rename to app/Services/ExchangeRateProviderService.php index ae52a8e4..e9d06684 100644 --- a/app/Services/Integrations/ExchangeRate/ExchangeRateProviderService.php +++ b/app/Services/ExchangeRateProviderService.php @@ -1,13 +1,13 @@