RateLimiter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
ccs 6
cts 6
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A initManager() 0 3 1
1
<?php
2
namespace RazonYang\Yii2\RateLimiter\Redis;
3
4
use yii\di\Instance;
5
use yii\redis\Connection;
6
use RazonYang\TokenBucket\ManagerInterface;
7
use RazonYang\Yii2\RateLimiter\BaseRateLimiter;
8
9
class RateLimiter extends BaseRateLimiter
10
{
11
    /**
12
     * @var Connectioin
0 ignored issues
show
Bug introduced by
The type RazonYang\Yii2\RateLimiter\Redis\Connectioin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
     */
14
    public $redis = 'redis';
15
16
    public $ttl = 3600;
17
18
    public $prefix = 'rate_limiter:';
19
20 2
    public function init()
21
    {
22 2
        $this->redis = Instance::ensure($this->redis, Connection::class);
23
24 2
        parent::init();
25 2
    }
26
27 2
    protected function initManager(): ManagerInterface
28
    {
29 2
        return new Manager($this->capacity, $this->rate, $this->getLogger(), $this->redis, $this->ttl, $this->prefix);
30
    }
31
}
32