Passed
Push — master ( 81ac1b...8d070d )
by Alexander
07:32
created

FakeCounter::setId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Yiisoft\Yii\RateLimiter\Tests;
4
5
use Yiisoft\Yii\RateLimiter\CounterInterface;
6
use Yiisoft\Yii\RateLimiter\CounterState;
7
8
final class FakeCounter implements CounterInterface
9
{
10
    private int $remaining;
11
    private int $limit;
12
    private int $reset;
13
    private string $id;
14
15
    public function __construct(int $limit, int $reset)
16
    {
17
        $this->reset = $reset;
18
        $this->limit = $limit;
19
        $this->remaining = $limit;
20
    }
21
22
    public function setId(string $id): void
23
    {
24
        $this->id = $id;
25
    }
26
27
    public function getId(): ?string
28
    {
29
        return $this->id;
30
    }
31
32
    public function incrementAndGetState(): CounterState
33
    {
34
        $this->remaining--;
35
        return new CounterState($this->limit, $this->remaining, $this->reset);
36
    }
37
}
38