Completed
Pull Request — master (#2)
by Kevin
01:28
created

ArrayPage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 4
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;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
10
    private int $offset;
11
    private int $limit;
12
    private int $totalCount;
13
14 35
    public function __construct(array $slice, int $offset, int $limit, int $totalCount)
15
    {
16 35
        $this->slice = $slice;
17 35
        $this->offset = $offset;
18 35
        $this->limit = $limit;
19 35
        $this->totalCount = $totalCount;
20 35
    }
21
22 4
    public function currentOffset(): int
23
    {
24 4
        return $this->offset;
25
    }
26
27 14
    public function currentPage(): int
28
    {
29 14
        return \floor($this->offset / $this->limit) + 1;
30
    }
31
32 12
    public function currentLimit(): int
33
    {
34 12
        return $this->limit;
35
    }
36
37 29
    public function count(): int
38
    {
39 29
        return \count($this->slice);
40
    }
41
42 12
    public function totalCount(): int
43
    {
44 12
        return $this->totalCount;
45
    }
46
47 31
    public function getIterator(): \Traversable
48
    {
49 31
        return new \ArrayIterator($this->slice);
50
    }
51
}
52