ArrayPage::totalCount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace Zenstruck\Porpaginas\Arrays;
4
5
use Zenstruck\Porpaginas\Page;
6
7
final class ArrayPage implements Page
8
{
9
    private array $slice;
10
    private int $offset;
11
    private int $limit;
12
    private int $totalCount;
13
14 22
    public function __construct(array $slice, int $offset, int $limit, int $totalCount)
15
    {
16 22
        $this->slice = $slice;
17 22
        $this->offset = $offset;
18 22
        $this->limit = $limit;
19 22
        $this->totalCount = $totalCount;
20 22
    }
21
22 4
    public function currentOffset(): int
23
    {
24 4
        return $this->offset;
25
    }
26
27 4
    public function currentPage(): int
28
    {
29 4
        return \floor($this->offset / $this->limit) + 1;
0 ignored issues
show
Bug Best Practice introduced by
The expression return floor($this->offset / $this->limit) + 1 returns the type double which is incompatible with the type-hinted return integer.
Loading history...
30
    }
31
32 4
    public function currentLimit(): int
33
    {
34 4
        return $this->limit;
35
    }
36
37 16
    public function count(): int
38
    {
39 16
        return \count($this->slice);
40
    }
41
42 2
    public function totalCount(): int
43
    {
44 2
        return $this->totalCount;
45
    }
46
47 18
    public function getIterator(): \Traversable
48
    {
49 18
        return new \ArrayIterator($this->slice);
50
    }
51
}
52