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

TwitterRateLimitException::getCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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