RedisHelper::testAsynchronousClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.064

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 8
ccs 3
cts 5
cp 0.6
crap 1.064
rs 10
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