RedisDsnProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A get() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use BEAR\RepositoryModule\Annotation\RedisDsn;
8
use BEAR\RepositoryModule\Annotation\RedisDsnOptions;
9
use Override;
10
use Predis\ClientInterface;
11
use Ray\Di\ProviderInterface;
12
use Redis;
13
use RedisArray;
14
use RedisCluster;
15
use Relay\Cluster as RelayCluster;
0 ignored issues
show
Bug introduced by
The type Relay\Cluster 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...
16
use Relay\Relay;
0 ignored issues
show
Bug introduced by
The type Relay\Relay 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...
17
use Symfony\Component\Cache\Adapter\RedisAdapter;
18
19
/** @implements ProviderInterface<Redis|RedisArray|RedisCluster|ClientInterface|Relay|RelayCluster> */
20
final class RedisDsnProvider implements ProviderInterface
21
{
22
    /**
23
     * @param string                                                   $dns     Redis DSN
24
     * @param array<string, bool|int|string|array<string, mixed>|null> $options Redis DSN Options
25
     */
26
    public function __construct(
27
        #[RedisDsn]
28
        private string $dns,
29
        #[RedisDsnOptions]
30
        private array $options,
31
    ) {
32
    }
33
34
    #[Override]
35
    public function get(): Redis|RedisArray|RedisCluster|ClientInterface|Relay|RelayCluster
36
    {
37
        /** @var Redis|RedisArray|RedisCluster|ClientInterface|Relay|RelayCluster $connection */
38
        $connection = RedisAdapter::createConnection($this->dns, $this->options);
39
40
        return $connection;
41
    }
42
}
43