Completed
Pull Request — master (#21)
by
unknown
04:41
created

LimitExceeded   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A for() 0 8 1
A getIdentifier() 0 4 1
A getRate() 0 4 1
A getStatus() 0 4 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