Completed
Push — master ( 712c83...97ed41 )
by Rémi
04:22
created

LimitedApiRate::nextWindow()   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\REST\Response;
4
5
class LimitedApiRate implements ApiRate
6
{
7
    /** @var int */
8
    private $limit;
9
10
    /** @var int */
11
    private $remaining;
12
13
    /** @var \DateTimeInterface */
14
    private $reset;
15
16
    /**
17
     * LimitedApiRate constructor.
18
     *
19
     * @param int $limit
20
     * @param int $remaining
21
     * @param int $reset
22
     */
23 9
    public function __construct(
24
        $limit,
25
        $remaining,
26
        $reset
27
    ) {
28 9
        $this->limit = $limit;
29 9
        $this->remaining = $remaining;
30 9
        $this->reset = \DateTimeImmutable::createFromFormat(
31 9
            'U',
32 9
            $reset,
33 9
            new \DateTimeZone('UTC')
34 6
        );
35 9
    }
36
37
    /**
38
     * @return int
39
     */
40 6
    public function getLimit()
41
    {
42 6
        return $this->limit;
43
    }
44
45
    /**
46
     * @return bool
47
     */
48 6
    public function canMakeAnotherCall()
49
    {
50 6
        return $this->remaining > 0;
51
    }
52
53
    /**
54
     * @return \DateTimeInterface
55
     */
56 9
    public function nextWindow()
57
    {
58 9
        return $this->reset;
59
    }
60
}
61