Completed
Pull Request — master (#180)
by Łukasz
02:58
created

PaginatorDetails::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
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 $parameters;
20
21
    public function __construct(string $route, array $parameters)
22
    {
23
        $this->route = $route;
24
        $this->limit = $parameters['limit'] ?? 10;
25
        $this->page = $parameters['page'] ?? 1;
26
        $this->parameters = $parameters;
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 parameters(): array
45
    {
46
        return $this->parameters;
47
    }
48
49
    public function addToParameters(string $key, $value): void
50
    {
51
        Assert::keyNotExists($this->parameters, $key);
52
53
        $this->parameters[$key] = $value;
54
    }
55
}
56