ResourceModule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use BEAR\Resource\Annotation\AppName;
8
use Override;
9
use Ray\Di\AbstractModule;
10
11
/**
12
 * Provides ResourceInterface and derived bindings
13
 *
14
 * The following module is installed:
15
 *
16
 * AppName
17
 *
18
 * The following module is installed:
19
 *
20
 * ResourceClientModule
21
 * AnnotationModule
22
 * EmbedResourceModule
23
 * HttpClientModule
24
 */
25
final class ResourceModule extends AbstractModule
26
{
27
    /** @param string $appName Application name ex) 'Vendor\Project' */
28
    public function __construct(
29
        private readonly string $appName = '',
30
    ) {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    #[Override]
38
    protected function configure(): void
39
    {
40
        $this->install(new ResourceClientModule());
41
        $this->install(new EmbedResourceModule());
42
        $this->install(new HttpClientModule());
43
        $this->bind()->annotatedWith(AppName::class)->toInstance($this->appName);
44
45
        // Backward compatibility
46
        /** @psalm-suppress DeprecatedClass */
47
        $this->install(new AnnotationModule());
0 ignored issues
show
Deprecated Code introduced by
The class BEAR\Resource\Module\AnnotationModule has been deprecated: See https://github.com/bearsunday/BEAR.Resource/wiki/Doctrine-annotation-deprecation-notice ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
        $this->install(/** @scrutinizer ignore-deprecated */ new AnnotationModule());
Loading history...
48
    }
49
}
50