Completed
Push — master ( 5c027e...c45ab2 )
by Nikola
03:38
created

LimitExceeded::getRate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RateLimit\Exception;
6
7
use RateLimit\Rate;
8
use RuntimeException;
9
10
final class LimitExceeded extends RuntimeException implements RateLimitException
11
{
12
    /** @var string */
13
    private $identifier;
14
15
    /** @var Rate */
16
    private $rate;
17
18 9
    public static function for(string $identifier, Rate $rate): self
19
    {
20 9
        $exception = new self(sprintf(
21 9
            'Limit has been exceeded for identifier "%s".',
22 9
            $identifier
23
        ));
24
25 9
        $exception->identifier = $identifier;
26 9
        $exception->rate = $rate;
27
28 9
        return $exception;
29
    }
30
31 9
    public function getIdentifier(): string
32
    {
33 9
        return $this->identifier;
34
    }
35
36 5
    public function getRate(): Rate
37
    {
38 5
        return $this->rate;
39
    }
40
}
41