RateLimiter::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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