MatchingCommandClassRateLimitProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A provide() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\Tactician\RateLimit\RateLimiter;
6
7
final class MatchingCommandClassRateLimitProvider implements RateLimitProviderInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $className;
13
    /**
14
     * @var int
15
     */
16
    private $limit;
17
    /**
18
     * @var int
19
     */
20
    private $milliseconds;
21
22 3
    public function __construct(string $className, int $limit, int $milliseconds)
23
    {
24 3
        $this->className = $className;
25 3
        $this->limit = $limit;
26 3
        $this->milliseconds = $milliseconds;
27 3
    }
28
29 3
    public function provide($command): ?RateLimit
30
    {
31 3
        if (!$command instanceof $this->className) {
32 1
            return null;
33
        }
34
35 2
        return new RateLimit($this->className, $this->limit, $this->milliseconds);
36
    }
37
}
38