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