PaginatorDetails::page()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Model;
6
7
use Webmozart\Assert\Assert;
8
9
final class PaginatorDetails
10
{
11
    /** @var string */
12
    private $route;
13
14
    /** @var int */
15
    private $limit;
16
17
    /** @var int */
18
    private $page;
19
20
    /** @var array */
21
    private $parameters;
22
23
    public function __construct(string $route, array $parameters)
24
    {
25
        $this->route = $route;
26
        $this->limit = (int) ($parameters['limit'] ?? 10);
27
        $this->page = (int) ($parameters['page'] ?? 1);
28
        $this->parameters = $parameters;
29
    }
30
31
    public function route(): string
32
    {
33
        return $this->route;
34
    }
35
36
    public function limit(): int
37
    {
38
        return $this->limit;
39
    }
40
41
    public function page(): int
42
    {
43
        return $this->page;
44
    }
45
46
    public function parameters(): array
47
    {
48
        return $this->parameters;
49
    }
50
51
    /**
52
     * @param mixed $value
53
     */
54
    public function addToParameters(string $key, $value): void
55
    {
56
        Assert::keyNotExists($this->parameters, $key);
57
58
        $this->parameters[$key] = $value;
59
    }
60
}
61