ResourceModule   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 7
c 5
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use BEAR\Resource\Annotation\AppName;
8
use Ray\Di\AbstractModule;
9
10
/**
11
 * Provides ResourceInterface and derived bindings
12
 *
13
 * The following module is installed:
14
 *
15
 * AppName
16
 *
17
 * The following module is installed:
18
 *
19
 * ResourceClientModule
20
 * AnnotationModule
21
 * EmbedResourceModule
22
 * HttpClientModule
23
 */
24
final class ResourceModule extends AbstractModule
25
{
26
    /** @param string $appName Application name ex) 'Vendor\Project' */
27
    public function __construct(
28
        private readonly string $appName = '',
29
    ) {
30
        parent::__construct();
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    protected function configure(): void
37
    {
38
        $this->install(new ResourceClientModule());
39
        $this->install(new EmbedResourceModule());
40
        $this->install(new HttpClientModule());
41
        $this->bind()->annotatedWith(AppName::class)->toInstance($this->appName);
42
43
        // Backward compatibility
44
        /** @psalm-suppress DeprecatedClass */
45
        $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

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