PaginatedRequest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldValidate() 0 4 1
A getVersionConstraint() 0 4 1
A getSchema() 0 4 1
A getPage() 0 4 1
A getPerPage() 0 4 1
A getOffset() 0 4 1
1
<?php
2
3
namespace App\Requests;
4
5
use JMS\Serializer\Annotation as JMS;
6
use Realshadow\RequestDeserializer\Contracts\RequestInterface;
7
8
9
class PaginatedRequest implements RequestInterface
10
{
11
12
    /**
13
     * @var int $page
14
     *
15
     * @JMS\Since("1.x")
16
     * @JMS\Type("integer")
17
     * @JMS\SerializedName("page")
18
     */
19
    private $page;
20
21
    /**
22
     * @var int $perPage
23
     *
24
     * @JMS\Since("1.x")
25
     * @JMS\Type("integer")
26
     * @JMS\SerializedName("per_page")
27
     */
28
    private $perPage;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function shouldValidate()
34
    {
35
        return true;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public static function getVersionConstraint()
42
    {
43
        return '1.0';
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function getSchema()
50
    {
51
        return resource_path('schemas/pagination.json');
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public function getPage()
58
    {
59
        return $this->page;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getPerPage()
66
    {
67
        return $this->perPage;
68
    }
69
70
    /**
71
     * @return int
72
     */
73
    public function getOffset()
74
    {
75
        return ($this->page - 1) * $this->perPage;
76
    }
77
78
}
79