Test Failed
Pull Request — master (#24)
by Herberto
05:13
created

KvkPaginator::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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 4
    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 4
        $this->itemsPerPage = $itemsPerPage;
33 4
        $this->startPage = $startPage;
34 4
        $this->totalItems = $totalItems;
35 4
        $this->items = $items;
36 4
        $this->nextUrl = $nextLink;
37 4
        $this->previousUrl = $previousLink;
38 4
    }
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
    public function getItems(): array
59
    {
60
        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