PaginationRequest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Test Coverage

Coverage 71.88%

Importance

Changes 0
Metric Value
wmc 11
eloc 26
dl 0
loc 143
ccs 23
cts 32
cp 0.7188
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setFirst() 0 5 1
A setLast() 0 5 1
A setBefore() 0 5 1
A __construct() 0 7 1
A getPage() 0 3 1
A getAfter() 0 3 1
A setAfter() 0 5 1
A setPage() 0 5 1
A getFirst() 0 3 1
A getLast() 0 3 1
A getBefore() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Pagination;
12
13
/**
14
 * PaginationRequest
15
 */
16
class PaginationRequest
17
{
18
    /**
19
     * @var int
20
     */
21
    protected $first;
22
23
    /**
24
     * @var int
25
     */
26
    protected $last;
27
28
    /**
29
     * @var string
30
     */
31
    protected $after;
32
33
    /**
34
     * @var string
35
     */
36
    protected $before;
37
38
    /**
39
     * @var int
40
     */
41
    protected $page;
42
43
    /**
44
     * PaginationRequest constructor.
45
     *
46
     * @param string|null $first
47
     * @param string|null $last
48
     * @param string|null $after
49
     * @param string|null $before
50
     * @param string|null $page
51
     */
52 6
    public function __construct($first = null, $last = null, $after = null, $before = null, $page = null)
53
    {
54 6
        $this->first = $first;
0 ignored issues
show
Documentation Bug introduced by
It seems like $first can also be of type string. However, the property $first is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
55 6
        $this->last = $last;
0 ignored issues
show
Documentation Bug introduced by
It seems like $last can also be of type string. However, the property $last is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
56 6
        $this->after = $after;
57 6
        $this->before = $before;
58 6
        $this->page = $page;
0 ignored issues
show
Documentation Bug introduced by
It seems like $page can also be of type string. However, the property $page is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
59 6
    }
60
61
    /**
62
     * @return int
63
     */
64 6
    public function getFirst(): ?int
65
    {
66 6
        return $this->first;
67
    }
68
69
    /**
70
     * @param int $first
71
     *
72
     * @return PaginationRequest
73
     */
74 1
    public function setFirst(int $first): PaginationRequest
75
    {
76 1
        $this->first = $first;
77
78 1
        return $this;
79
    }
80
81
    /**
82
     * @return int
83
     */
84 6
    public function getLast(): ?int
85
    {
86 6
        return $this->last;
87
    }
88
89
    /**
90
     * @param int $last
91
     *
92
     * @return PaginationRequest
93
     */
94 1
    public function setLast(int $last): PaginationRequest
95
    {
96 1
        $this->last = $last;
97
98 1
        return $this;
99
    }
100
101
    /**
102
     * @return string
103
     */
104 4
    public function getAfter(): ?string
105
    {
106 4
        return $this->after;
107
    }
108
109
    /**
110
     * @param string $after
111
     *
112
     * @return PaginationRequest
113
     */
114
    public function setAfter(string $after): PaginationRequest
115
    {
116
        $this->after = $after;
117
118
        return $this;
119
    }
120
121
    /**
122
     * @return string
123
     */
124 6
    public function getBefore(): ?string
125
    {
126 6
        return $this->before;
127
    }
128
129
    /**
130
     * @param string $before
131
     *
132
     * @return PaginationRequest
133
     */
134
    public function setBefore(string $before): PaginationRequest
135
    {
136
        $this->before = $before;
137
138
        return $this;
139
    }
140
141
    /**
142
     * @return int|null
143
     */
144 6
    public function getPage(): ?int
145
    {
146 6
        return $this->page;
147
    }
148
149
    /**
150
     * @param int $page
151
     *
152
     * @return PaginationRequest
153
     */
154
    public function setPage(int $page): PaginationRequest
155
    {
156
        $this->page = $page;
157
158
        return $this;
159
    }
160
}
161