Completed
Pull Request — master (#21)
by
unknown
04:41
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 RateLimit\Status;
9
use RuntimeException;
10
11
final class LimitExceeded extends RuntimeException
12
{
13
    /** @var Rate */
14
    protected $rate;
15
16
    /** @var Status */
17
    protected $status;
18
19 2
    public static function for(Status $status, Rate $rate): self
20
    {
21 2
        $exception = new self("Limit of has been exceeded by identifier: {$status->getIdentifier()}");
22 2
        $exception->rate = $rate;
23 2
        $exception->status = $status;
24
25 2
        return $exception;
26
    }
27
28 2
    public function getIdentifier(): string
29
    {
30 2
        return $this->status->getIdentifier();
31
    }
32
33 1
    public function getRate(): Rate
34
    {
35 1
        return $this->rate;
36
    }
37
38 2
    public function getStatus(): Status
39
    {
40 2
        return $this->status;
41
    }
42
}
43