RedisHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 10
cp 0.8
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAsynchronousClient() 0 8 1
A isRedisDSN() 0 4 2
1
<?php
2
3
namespace BenTools\MercurePHP\Helpers;
4
5
use Clue\React\Redis\Client as AsynchronousClient;
6
use Psr\Log\LoggerInterface;
7
use React\EventLoop\LoopInterface;
8
9
final class RedisHelper
10
{
11 2
    public static function testAsynchronousClient(AsynchronousClient $client, LoopInterface $loop, LoggerInterface $logger): void
12
    {
13
        /** @phpstan-ignore-next-line */
14 2
        $client->get('foo')->then(
15 2
            null,
16
            function (\Exception $e) use ($loop, $logger) {
17
                $logger->error(\sprintf('Redis error: %s', $e->getMessage()));
18
                $loop->stop();
19 2
            }
20
        );
21 2
    }
22
23 9
    public static function isRedisDSN(string $dsn): bool
24
    {
25 9
        return 0 === strpos($dsn, 'redis://')
26 9
            || 0 === strpos($dsn, 'rediss://');
27
    }
28
}
29