RedisHelper::isRedisDSN()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
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