Completed
Push — master ( 257c19...712c83 )
by Rémi
04:23
created

TwitterRateLimitException::getCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 0
crap 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 3
    public function getCategory()
19
    {
20 3
        return $this->category;
21
    }
22
23
    /**
24
     * @return \DateTimeInterface
25
     */
26 3
    public function nextWindow()
27
    {
28 3
        return $this->rate->nextWindow();
29
    }
30
31
    /**
32
     * @param string  $category
33
     * @param ApiRate $rate
34
     *
35
     * @return TwitterRateLimitException
36
     */
37 3
    public static function create($category, ApiRate $rate)
38
    {
39 3
        $exception = new self('You have reached rate limit. You cannot make an API call yet.');
40 3
        $exception->category = $category;
41 3
        $exception->rate = $rate;
42
43 3
        return $exception;
44
    }
45
}
46