GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ResourceCursor::getLimit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaignApi\Paginator;
7
8
/**
9
 * Class ResourceCursor
10
 */
11
class ResourceCursor implements ResourceCursorInterface
12
{
13
    /**
14
     * @var int|null
15
     */
16
    private $limit;
17
18
    /**
19
     * @var PageInterface
20
     */
21
    private $currentPage;
22
23
    /**
24
     * @var PageInterface
25
     */
26
    private $firstPage;
27
28
    /**
29
     * @var int
30
     */
31
    private $currentIndex = 0;
32
33
    /**
34
     * @var int
35
     */
36
    private $totalIndex = 0;
37
38
    /**
39
     * @param int|null $limit
40
     * @param PageInterface $firstPage
41
     */
42
    public function __construct(?int $limit, PageInterface $firstPage)
43
    {
44
        $this->limit = $limit;
45
        $this->currentPage = $firstPage;
46
        $this->firstPage = $firstPage;
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function current()
53
    {
54
        return $this->currentPage->getItems()[$this->currentIndex];
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function next()
61
    {
62
        $this->currentIndex++;
63
        $this->totalIndex++;
64
65
        $items = $this->currentPage->getItems();
66
67
        if (!isset($items[$this->currentIndex]) && $this->currentPage->hasNextPage()) {
68
            $this->currentIndex = 0;
69
            $this->currentPage = $this->currentPage->getNextPage();
70
        }
71
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    public function key()
77
    {
78
        return $this->totalIndex;
79
    }
80
81
    /**
82
     * @inheritDoc
83
     */
84
    public function valid()
85
    {
86
        return isset($this->currentPage->getItems()[$this->currentIndex]);
87
    }
88
89
    /**
90
     * @inheritDoc
91
     */
92
    public function rewind()
93
    {
94
        $this->totalIndex = 0;
95
        $this->currentIndex = 0;
96
        $this->currentPage = $this->firstPage;
97
    }
98
99
    /**
100
     * @inheritDoc
101
     */
102
    public function getLimit(): ?int
103
    {
104
        return $this->limit;
105
    }
106
}
107