KvkPaginator::getNextUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Werkspot\KvkApi\Client;
6
7
use Werkspot\KvkApi\Client\Exception\PageDoesNotExistException;
8
use Werkspot\KvkApi\Client\Profile\Company as ProfileCompany;
9
10
final class KvkPaginator implements KvkPaginatorInterface
11
{
12
    private $itemsPerPage;
13
14
    private $startPage;
15
16
    private $totalItems;
17
18
    private $items;
19
20
    private $nextUrl;
21
22
    private $previousUrl;
23
24 36
    public function __construct(
25
        int $itemsPerPage,
26
        int $startPage,
27
        int $totalItems,
28
        array $items,
29
        ?string $nextLink = null,
30
        ?string $previousLink = null
31
    ) {
32 36
        $this->itemsPerPage = $itemsPerPage;
33 36
        $this->startPage = $startPage;
34 36
        $this->totalItems = $totalItems;
35 36
        $this->items = $items;
36 36
        $this->nextUrl = $nextLink;
37 36
        $this->previousUrl = $previousLink;
38 36
    }
39
40 1
    public function getItemsPerPage(): int
41
    {
42 1
        return $this->itemsPerPage;
43
    }
44
45 1
    public function getStartPage(): int
46
    {
47 1
        return $this->startPage;
48
    }
49
50 1
    public function getTotalItems(): int
51
    {
52 1
        return $this->totalItems;
53
    }
54
55
    /**
56
     * @return ProfileCompany[]
57
     */
58 32
    public function getItems(): array
59
    {
60 32
        return $this->items;
61
    }
62
63 2
    public function getNextUrl(): string
64
    {
65 2
        if (!$this->nextUrl) {
66
            throw new PageDoesNotExistException();
67
        }
68
69 2
        return $this->nextUrl;
70
    }
71
72 2
    public function getPreviousUrl(): string
73
    {
74 2
        if (!$this->previousUrl) {
75
            throw new PageDoesNotExistException();
76
        }
77
78 2
        return $this->previousUrl;
79
    }
80
}
81