Completed
Push — master ( d83f32...d4821e )
by Rémi
04:29
created

TwitterRateLimitException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 39
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCategory() 0 4 1
A nextWindow() 0 4 1
A create() 0 8 1
1
<?php
2
3
namespace Twitter\API\Exception;
4
5
use Twitter\API\REST\Response\ApiRate;
6
7
class TwitterRateLimitException extends TwitterException
8
{
9
    /** @var string */
10
    private $category;
11
12
    /** @var ApiRate */
13
    private $rate;
14
15
    /**
16
     * @return string
17
     */
18
    public function getCategory()
19
    {
20
        return $this->category;
21
    }
22
23
    /**
24
     * @return \DateTimeInterface
25
     */
26
    public function nextWindow()
27
    {
28
        return $this->rate->nextWindow();
29
    }
30
31
    /**
32
     * @param string  $category
33
     * @param ApiRate $rate
34
     *
35
     * @return TwitterRateLimitException
36
     */
37
    public static function create($category, ApiRate $rate)
38
    {
39
        $exception = new self('You have reached rate limit. You cannot make an API call yet.');
40
        $exception->category = $category;
41
        $exception->rate = $rate;
42
43
        return $exception;
44
    }
45
}
46