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

LimitedApiRate::canMakeAnotherCall()   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\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
    public function __construct(
24
        $limit,
25
        $remaining,
26
        $reset
27
    ) {
28
        $this->limit = $limit;
29
        $this->remaining = $remaining;
30
        $this->reset = \DateTimeImmutable::createFromFormat(
31
            'U',
32
            $reset,
33
            new \DateTimeZone('UTC')
34
        );
35
    }
36
37
    /**
38
     * @return int
39
     */
40
    public function getLimit()
41
    {
42
        return $this->limit;
43
    }
44
45
    /**
46
     * @return bool
47
     */
48
    public function canMakeAnotherCall()
49
    {
50
        return $this->remaining > 0;
51
    }
52
53
    /**
54
     * @return \DateTimeInterface
55
     */
56
    public function nextWindow()
57
    {
58
        return $this->reset;
59
    }
60
}
61