ImportAppModule::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use BEAR\Resource\Annotation\ImportAppConfig;
8
use BEAR\Resource\ImportApp;
9
use BEAR\Resource\SchemeCollectionInterface;
10
use Override;
11
use Ray\Di\AbstractModule;
12
use Ray\Di\Exception\NotFound;
13
14
final class ImportAppModule extends AbstractModule
15
{
16
    /**
17
     * Import scheme config
18
     *
19
     * @var array<ImportApp>
20
     */
21
    private array $importAppConfig = [];
22
23
    /** @param array<ImportApp> $importApps */
24
    public function __construct(array $importApps, string $defaultContextName = '')
25
    {
26
        foreach ($importApps as $importApp) {
27
            // create import config
28
            $this->importAppConfig[] = $importApp;
29
        }
30
31
        unset($defaultContextName);
32
33
        parent::__construct();
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     *
39
     * @throws NotFound
40
     */
41
    #[Override]
42
    protected function configure(): void
43
    {
44
        $this->bind()->annotatedWith(ImportAppConfig::class)->toInstance($this->importAppConfig);
45
        $this->bind(SchemeCollectionInterface::class)->toProvider(ImportSchemeCollectionProvider::class);
46
    }
47
}
48