Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
30 | public static function createRedisBackedRateLimiter(array $redisOptions = [], int $limit = self::DEFAULT_LIMIT, int $window = self::DEFAULT_WINDOW) : RateLimiterInterface |
||
31 | { |
||
32 | $redisOptions = array_merge([ |
||
33 | 'host' => '127.0.0.1', |
||
34 | 'port' => 6379, |
||
35 | 'timeout' => 0.0, |
||
36 | ], $redisOptions); |
||
37 | |||
38 | $redis = new Redis(); |
||
39 | |||
40 | $redis->connect($redisOptions['host'], $redisOptions['port'], $redisOptions['timeout']); |
||
41 | |||
42 | return new RedisRateLimiter($redis, $limit, $window); |
||
43 | } |
||
44 | } |
||
45 |