Completed
Push — master ( e95787...a7a4ec )
by Thijs
25s queued 22s
created

PaginatedResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 84
ccs 13
cts 13
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A perPage() 0 3 1
A __construct() 0 6 1
A currentPage() 0 3 1
A total() 0 3 1
A items() 0 3 1
1
<?php
2
3
namespace TestMonitor\DoneDone\Responses;
4
5
class PaginatedResponse
6
{
7
    /**
8
     * All of the items being paginated.
9
     *
10
     * @var array
11
     */
12
    protected array $items;
13
14
    /**
15
     * The total number of items before slicing.
16
     *
17
     * @var int
18
     */
19
    protected int $total;
20
21
    /**
22
     * The number of items to be shown per page.
23
     *
24
     * @var int
25
     */
26
    protected int $perPage;
27
28
    /**
29
     * The current page.
30
     *
31
     * @var int
32
     */
33
    protected int $currentPage;
34
35
    /**
36
     * Create a new paginated response instance.
37
     *
38
     * @param array $items
39
     * @param int $total
40
     * @param int $perPage
41
     * @param int $currentPage
42
     */
43 1
    public function __construct(array $items, int $total, int $perPage, int $currentPage = 1)
44
    {
45 1
        $this->items = $items;
46 1
        $this->total = $total;
47 1
        $this->perPage = $perPage;
48 1
        $this->currentPage = $currentPage;
49
    }
50
51
    /**
52
     * Get the items being paginated.
53
     *
54
     * @return array
55
     */
56 1
    public function items(): array
57
    {
58 1
        return $this->items;
59
    }
60
61
    /**
62
     * Get the total number of items being paginated.
63
     *
64
     * @return int
65
     */
66 1
    public function total(): int
67
    {
68 1
        return $this->total;
69
    }
70
71
    /**
72
     * Get the number of items shown per page.
73
     *
74
     * @return int
75
     */
76 1
    public function perPage(): int
77
    {
78 1
        return $this->perPage;
79
    }
80
81
    /**
82
     * Get the current page.
83
     *
84
     * @return int
85
     */
86 1
    public function currentPage(): int
87
    {
88 1
        return $this->currentPage;
89
    }
90
}
91