Passed
Pull Request — master (#26)
by Wanderson
02:55
created

Pagination   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A offset() 0 7 3
1
<?php
2
3
namespace Win\Services;
4
5
/**
6
 * Auxilia criar paginações
7
 */
8
class Pagination
9
{
10
	public int $current = 1;
11
	public int $pageSize = 0;
12
	public int $count = 0;
13
	public int $last = 0;
14
15
	public function offset()
16
	{
17
		if ($this->pageSize && $this->count) {
18
			$this->last = ceil($this->count / $this->pageSize);
19
			$this->current = min(max($this->current, 1), $this->last);
20
		}
21
		return $this->pageSize * ($this->current - 1);
22
	}
23
}
24