Passed
Push — master ( 7cd6c5...dd963e )
by Laurens
04:05
created

KvkPaginator   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 1
dl 0
loc 66
ccs 22
cts 24
cp 0.9167
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getItemsPerPage() 0 4 1
A getStartPage() 0 4 1
A getTotalItems() 0 4 1
A getItems() 0 4 1
A getNextUrl() 0 8 2
A getPreviousUrl() 0 8 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
    private $startPage;
14
    private $totalItems;
15
    private $items;
16
    private $nextUrl;
17
    private $previousUrl;
18
19 20
    public function __construct(
20
        int $itemsPerPage,
21
        int $startPage,
22
        int $totalItems,
23
        array $items,
24
        ?string $nextLink = null,
25
        ?string $previousLink = null
26
    ) {
27 20
        $this->itemsPerPage = $itemsPerPage;
28 20
        $this->startPage = $startPage;
29 20
        $this->totalItems = $totalItems;
30 20
        $this->items = $items;
31 20
        $this->nextUrl = $nextLink;
32 20
        $this->previousUrl = $previousLink;
33 20
    }
34
35 1
    public function getItemsPerPage(): int
36
    {
37 1
        return $this->itemsPerPage;
38
    }
39
40 1
    public function getStartPage(): int
41
    {
42 1
        return $this->startPage;
43
    }
44
45 1
    public function getTotalItems(): int
46
    {
47 1
        return $this->totalItems;
48
    }
49
50
    /**
51
     * @return ProfileCompany[]
52
     */
53 16
    public function getItems(): array
54
    {
55 16
        return $this->items;
56
    }
57
58 2
    public function getNextUrl(): string
59
    {
60 2
        if (!$this->nextUrl) {
61
            throw new PageDoesNotExistException();
62
        }
63
64 2
        return $this->nextUrl;
65
    }
66
67 2
    public function getPreviousUrl(): string
68
    {
69 2
        if (!$this->previousUrl) {
70
            throw new PageDoesNotExistException();
71
        }
72
73 2
        return $this->previousUrl;
74
    }
75
}
76