StorageMemcachedModule   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 24
rs 10
ccs 9
cts 9
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use BEAR\RepositoryModule\Annotation\ResourceObjectPool;
8
use BEAR\RepositoryModule\Annotation\TagsPool;
9
use Override;
10
use Ray\Di\AbstractModule;
11
use Ray\PsrCacheModule\Annotation\CacheNamespace;
12
use Ray\PsrCacheModule\MemcachedAdapter;
13
use Ray\PsrCacheModule\Psr6MemcachedModule;
14
use Symfony\Component\Cache\Adapter\AdapterInterface;
15
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
16
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
17
18
final class StorageMemcachedModule extends AbstractModule
19
{
20 1
    /** @param string $servers 'mem1.domain.com:11211:33,mem2.domain.com:11211:67' {host}:{port}:{weight} */
21 1
    public function __construct(
22 1
        private readonly string $servers,
23 1
        AbstractModule|null $module = null,
24 1
    ) {
25
        parent::__construct($module);
26
    }
27
28
    /**
29 1
     * {@inheritDoc}
30
     */
31 1
    #[Override]
32 1
    protected function configure(): void
33 1
    {
34
        $this->bind(AdapterInterface::class)->annotatedWith(ResourceObjectPool::class)->to(MemcachedAdapter::class);
35
        $this->install(new Psr6MemcachedModule($this->servers));
36
        $this->bind(TagAwareAdapterInterface::class)->annotatedWith(ResourceObjectPool::class)->toConstructor(
37
            TagAwareAdapter::class,
38
            [
39
                'itemsPool' => ResourceObjectPool::class,
40
                'tagsPool' => TagsPool::class,
41
                'namespace' => CacheNamespace::class,
42
            ],
43
        );
44
    }
45
}
46