RedisProxyThrottleTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 4 2
A createStore() 0 9 2
1
<?php
2
3
namespace Zenstruck\Governator\Tests\Integration\Redis;
4
5
use Symfony\Component\Cache\Adapter\RedisAdapter;
6
use Symfony\Component\Cache\Traits\RedisProxy;
7
use Zenstruck\Governator\Store;
8
use Zenstruck\Governator\Store\RedisStore;
9
use Zenstruck\Governator\Tests\Integration\BaseThrottleTest;
10
11
/**
12
 * @requires extension redis
13
 * @group time-sensitive
14
 *
15
 * @author Kevin Bond <[email protected]>
16
 */
17
final class RedisProxyThrottleTest extends BaseThrottleTest
18
{
19
    public static function setUpBeforeClass(): void
20
    {
21
        if (!\getenv('REDIS_HOST')) {
22
            self::markTestSkipped('REDIS_HOST not configured.');
23
        }
24
    }
25
26
    protected function createStore(): Store
27
    {
28
        $connection = RedisAdapter::createConnection('redis://'.\getenv('REDIS_HOST'), ['lazy' => true]);
29
30
        if (!$connection instanceof RedisProxy) {
31
            throw new \RuntimeException('Expected instance of '.RedisProxy::class);
32
        }
33
34
        return new RedisStore($connection);
35
    }
36
}
37