Passed
Pull Request — 1.x (#334)
by Akihito
11:25
created

SemanticLoggerModule::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\SemanticLog\Module;
6
7
use BEAR\Resource\Invoker;
8
use BEAR\Resource\InvokerInterface;
9
use BEAR\Resource\SemanticLog\SemanticResourceInvokerAdapter;
10
use Koriym\SemanticLogger\SemanticLogger;
11
use Koriym\SemanticLogger\SemanticLoggerInterface;
12
use Override;
13
use Ray\Di\AbstractModule;
14
use Ray\Di\Scope;
15
16
final class SemanticLoggerModule extends AbstractModule
17
{
18
    #[Override]
19
    protected function configure(): void
20
    {
21
        $this->bind(SemanticLoggerInterface::class)->to(SemanticLogger::class)->in(Scope::SINGLETON);
22
23
        // Bind the original invoker with annotation so our adapter can inject it
24
        $this->bind(InvokerInterface::class)->annotatedWith('Original')->to(Invoker::class);
25
26
        // Override the default invoker with our semantic logging adapter
27
        $this->bind(InvokerInterface::class)->to(SemanticResourceInvokerAdapter::class);
28
    }
29
}
30