Completed
Pull Request — master (#180)
by Łukasz
05:27 queued 02:14
created

PaginatorDetails   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A route() 0 4 1
A limit() 0 4 1
A page() 0 4 1
A getParameters() 0 4 1
A addParameter() 0 6 1
1
<?php
2
3
namespace Sylius\ShopApiPlugin\Model;
4
5
use Webmozart\Assert\Assert;
6
7
final class PaginatorDetails
8
{
9
    /** @var string */
10
    private $route;
11
12
    /** @var int */
13
    private $limit;
14
15
    /** @var int */
16
    private $page;
17
18
    /** @var array */
19
    private $getParameters;
20
21
    public function __construct(string $route, array $getParameters)
22
    {
23
        $this->route = $route;
24
        $this->limit = $getParameters['limit'] ?? 10;
25
        $this->page = $getParameters['page'] ?? 1;
26
        $this->getParameters = $getParameters;
27
    }
28
29
    public function route(): string
30
    {
31
        return $this->route;
32
    }
33
34
    public function limit(): int
35
    {
36
        return $this->limit;
37
    }
38
39
    public function page(): int
40
    {
41
        return $this->page;
42
    }
43
44
    public function getParameters(): array
45
    {
46
        return $this->getParameters;
47
    }
48
49
    public function addParameter(string $key, string $value)
50
    {
51
        Assert::keyNotExists($this->getParameters, $key);
52
53
        $this->getParameters[$key] = $value;
54
    }
55
}
56