ImportAppModule   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 2
b 0
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A configure() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Module;
6
7
use BEAR\AppMeta\Meta;
8
use BEAR\Package\Module\Import\ImportApp;
9
use BEAR\Resource\Annotation\ImportAppConfig;
10
use BEAR\Resource\Module\SchemeCollectionProvider;
0 ignored issues
show
Bug introduced by
The type BEAR\Resource\Module\SchemeCollectionProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use BEAR\Resource\SchemeCollectionInterface;
12
use Override;
13
use Ray\Di\AbstractModule;
14
use Ray\Di\Exception\NotFound;
15
16
/**
17
 * Provides SchemeCollectionInterface and derived bindings
18
 *
19
 * The following bindings are provided:
20
 *
21
 * SchemeCollectionInterface
22
 * SchemeCollectionInterface:original
23
 * :ImportAppConfig
24
 */
25
final class ImportAppModule extends AbstractModule
26
{
27
    /**
28
     * Import scheme config
29
     *
30
     * @var array<ImportApp>
31
     */
32
    private array $importApps = [];
33
34
    /** @param array<ImportApp> $importApps */
35
    public function __construct(array $importApps)
36
    {
37
        foreach ($importApps as $importApp) {
38
            // create import config
39
            $this->importApps[] = $importApp;
40
        }
41
42
        parent::__construct();
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     *
48
     * @throws NotFound
49
     */
50
    #[Override]
51
    protected function configure(): void
52
    {
53
        $this->bind()->annotatedWith(ImportAppConfig::class)->toInstance($this->importApps);
54
        $this->bind(SchemeCollectionInterface::class)->annotatedWith('original')->toProvider(SchemeCollectionProvider::class);
55
        $this->bind(SchemeCollectionInterface::class)->toProvider(ImportSchemeCollectionProvider::class);
56
        foreach ($this->importApps as $app) {
57
            $meta = new Meta($app->appName, $app->context, $app->appDir);
58
            $this->install(new ResourceObjectModule($meta->getResourceListGenerator()));
59
        }
60
    }
61
}
62