Completed
Push — master ( 03ee46...05e56c )
by Alejandro
24s queued 10s
created

VisitsPaginatorAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getItems() 0 7 1
A count() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Core\Paginator\Adapter;
5
6
use Shlinkio\Shlink\Core\Model\VisitsParams;
7
use Shlinkio\Shlink\Core\Repository\VisitRepositoryInterface;
8
use Zend\Paginator\Adapter\AdapterInterface;
9
10
class VisitsPaginatorAdapter implements AdapterInterface
11
{
12
    /** @var VisitRepositoryInterface */
13
    private $visitRepository;
14
    /** @var string */
15
    private $shortCode;
16
    /** @var VisitsParams */
17
    private $params;
18
19 1
    public function __construct(VisitRepositoryInterface $visitRepository, string $shortCode, VisitsParams $params)
20
    {
21 1
        $this->visitRepository = $visitRepository;
22 1
        $this->shortCode = $shortCode;
23 1
        $this->params = $params;
24
    }
25
26 1
    public function getItems($offset, $itemCountPerPage): array
27
    {
28 1
        return $this->visitRepository->findVisitsByShortCode(
29 1
            $this->shortCode,
30 1
            $this->params->getDateRange(),
31 1
            $itemCountPerPage,
32 1
            $offset
33
        );
34
    }
35
36 1
    public function count(): int
37
    {
38 1
        return $this->visitRepository->countVisitsByShortCode($this->shortCode, $this->params->getDateRange());
39
    }
40
}
41