Passed
Pull Request — master (#19)
by Vadim
02:20
created

CounterState::isLimitReached()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\RateLimiter;
6
7
/**
8
 * @psalm-immutable
9
 */
10
final class CounterState
11
{
12
    public int $limit;
13
    public int $remaining;
14
    public int $resetTime;
15
    public bool $isLimitReached;
16
17
    /**
18
     * @param int $limit The maximum number of requests allowed with a time period.
19
     * @param int $remaining The number of remaining requests in the current time period.
20
     * @param int $resetTime Timestamp to wait until the rate limit resets.
21
     */
22 8
    public function __construct(int $limit, int $remaining, int $resetTime)
23
    {
24 8
        $this->limit = $limit;
25 8
        $this->remaining = $remaining;
26 8
        $this->resetTime = $resetTime;
27 8
        $this->isLimitReached = 0 === $remaining;
28 8
    }
29
}
30