Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
IntegrationsServiceProvider
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
6
100.00% covered (success)
100.00%
1 / 1
 getDefinitions
100.00% covered (success)
100.00%
24 / 24
100.00% covered (success)
100.00%
1 / 1
5
 getExtensions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Integrations\Config;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Integrations\Application\Service\CompromisedPasswordCheckService;
12use App\Modules\Integrations\Application\Service\EmailSecurityScanner;
13use App\Modules\Integrations\Infrastructure\Provider\DemoMockSecurityProvider;
14use App\Modules\Integrations\Infrastructure\Provider\HaveIBeenPwnedProvider;
15use App\Modules\Integrations\Infrastructure\Security\SsrfProtectionClient;
16use App\Modules\Integrations\Infrastructure\Security\SsrfProtectionClientInterface;
17use PDO;
18use Psr\Container\ContainerInterface;
19use Yiisoft\Cache\CacheInterface;
20use 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 */
29final 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}