ShortUrlRepositoryAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A count() 0 6 1
A getItems() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Core\Paginator\Adapter;
6
7
use Laminas\Paginator\Adapter\AdapterInterface;
8
use Shlinkio\Shlink\Core\Model\ShortUrlsParams;
9
use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface;
10
11
class ShortUrlRepositoryAdapter implements AdapterInterface
12
{
13
    private ShortUrlRepositoryInterface $repository;
14
    private ShortUrlsParams $params;
15
16 24
    public function __construct(ShortUrlRepositoryInterface $repository, ShortUrlsParams $params)
17
    {
18 24
        $this->repository = $repository;
19 24
        $this->params = $params;
20 24
    }
21
22
    public function getItems($offset, $itemCountPerPage): array // phpcs:ignore
23
    {
24
        return $this->repository->findList(
25
            $itemCountPerPage,
26
            $offset,
27
            $this->params->searchTerm(),
28 13
            $this->params->tags(),
29
            $this->params->orderBy(),
30 13
            $this->params->dateRange(),
31
        );
32
    }
33 13
34 13
    public function count(): int
35 13
    {
36 13
        return $this->repository->countList(
37
            $this->params->searchTerm(),
38
            $this->params->tags(),
39
            $this->params->dateRange(),
40
        );
41
    }
42
}
43