Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| IntegrationsServiceProvider | |
100.00% |
25 / 25 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
| getDefinitions | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
5 | |||
| getExtensions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Integrations\Config; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use App\Modules\Integrations\Application\Service\CompromisedPasswordCheckService; |
| 12 | use App\Modules\Integrations\Application\Service\EmailSecurityScanner; |
| 13 | use App\Modules\Integrations\Infrastructure\Provider\DemoMockSecurityProvider; |
| 14 | use App\Modules\Integrations\Infrastructure\Provider\HaveIBeenPwnedProvider; |
| 15 | use App\Modules\Integrations\Infrastructure\Security\SsrfProtectionClient; |
| 16 | use App\Modules\Integrations\Infrastructure\Security\SsrfProtectionClientInterface; |
| 17 | use PDO; |
| 18 | use Psr\Container\ContainerInterface; |
| 19 | use Yiisoft\Cache\CacheInterface; |
| 20 | use Yiisoft\Di\ServiceProviderInterface; |
| 21 | |
| 22 | /** |
| 23 | * IntegrationsModuleServiceProvider. |
| 24 | * |
| 25 | * Configures DI container definitions for Integrations, SSRF protection, and Security Scanner. |
| 26 | * |
| 27 | * @package App\Modules\Integrations\Config |
| 28 | */ |
| 29 | final class IntegrationsServiceProvider implements ServiceProviderInterface |
| 30 | { |
| 31 | /** |
| 32 | * @return array<string, mixed> Definitions mapping for PSR-11 container. |
| 33 | */ |
| 34 | public function getDefinitions(): array |
| 35 | { |
| 36 | return [ |
| 37 | SsrfProtectionClient::class => static fn(): SsrfProtectionClient => new SsrfProtectionClient(), |
| 38 | SsrfProtectionClientInterface::class => static fn(ContainerInterface $c): SsrfProtectionClientInterface => ( |
| 39 | $c->get(SsrfProtectionClient::class) |
| 40 | ), |
| 41 | DemoMockSecurityProvider::class => static fn(): DemoMockSecurityProvider => new DemoMockSecurityProvider(), |
| 42 | HaveIBeenPwnedProvider::class => static fn(ContainerInterface $c): HaveIBeenPwnedProvider => ( |
| 43 | new HaveIBeenPwnedProvider($c->get(SsrfProtectionClientInterface::class)) |
| 44 | ), |
| 45 | CompromisedPasswordCheckService::class => static fn( |
| 46 | ContainerInterface $c |
| 47 | ): CompromisedPasswordCheckService => new CompromisedPasswordCheckService( |
| 48 | $c->has(PDO::class) ? $c->get(PDO::class) : null, |
| 49 | $c->get(HaveIBeenPwnedProvider::class), |
| 50 | $c->has(CacheInterface::class) ? $c->get(CacheInterface::class) : null |
| 51 | ), |
| 52 | EmailSecurityScanner::class => static fn(ContainerInterface $c): EmailSecurityScanner => ( |
| 53 | new EmailSecurityScanner( |
| 54 | $c->has(PDO::class) ? $c->get(PDO::class) : null, |
| 55 | $c->has(CacheInterface::class) ? $c->get(CacheInterface::class) : null, |
| 56 | $c->get(SsrfProtectionClient::class) |
| 57 | ) |
| 58 | ), |
| 59 | ]; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @return array<string, mixed> Service extensions mapping. |
| 64 | */ |
| 65 | public function getExtensions(): array |
| 66 | { |
| 67 | return []; |
| 68 | } |
| 69 | } |