PaginatedRequest::getSchema()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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