PaginatorDetails   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

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 parameters() 0 4 1
A addToParameters() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\ShopApiPlugin\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
    public function addToParameters(string $key, $value): void
52
    {
53
        Assert::keyNotExists($this->parameters, $key);
54
55
        $this->parameters[$key] = $value;
56
    }
57
}
58