Skip to content

Commit cba4f51

Browse files
committed
refactor: use interface types for ApiService and GateService in DI
Register services with setType(Interface)->setFactory(Implementation) so the container exposes ApiServiceInterface and GateServiceInterface rather than concrete classes.
1 parent 7fe6ea4 commit cba4f51

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/DI/ThePayExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
use Nette\Schema\Expect;
77
use Nette\Schema\Schema;
88
use ThePay\ApiClient\Service\ApiService;
9+
use ThePay\ApiClient\Service\ApiServiceInterface;
910
use ThePay\ApiClient\Service\GateService;
11+
use ThePay\ApiClient\Service\GateServiceInterface;
1012
use ThePay\ApiClient\Service\SignatureService;
1113
use ThePay\ApiClient\TheClient;
1214
use ThePay\ApiClient\TheConfig;
@@ -58,10 +60,12 @@ public function beforeCompile(): void
5860
->setType(SignatureService::class);
5961

6062
$builder->addDefinition($this->prefix('apiService'))
61-
->setType(ApiService::class);
63+
->setType(ApiServiceInterface::class)
64+
->setFactory(ApiService::class);
6265

6366
$builder->addDefinition($this->prefix('gateService'))
64-
->setType(GateService::class);
67+
->setType(GateServiceInterface::class)
68+
->setFactory(GateService::class);
6569

6670
$builder->addDefinition($this->prefix('client'))
6771
->setType(TheClient::class);

0 commit comments

Comments
 (0)