ShortUrlRepositoryAdapter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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