1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Vehicle\App\Query; |
4
|
|
|
|
5
|
|
|
use App\Common\App\Transformer\AppGlobalId; |
6
|
|
|
use Overblog\GraphQLBundle\Definition\Argument; |
7
|
|
|
|
8
|
|
|
class VehiclesQuery |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
private $personId; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $vehicleId; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $after; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
private $offset; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
private $limit; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string|null $personId |
37
|
|
|
* @param string|null $vehicleId |
38
|
|
|
* @param string|null $after |
39
|
|
|
* @param int|null $offset |
40
|
|
|
* @param int|null $limit |
41
|
|
|
*/ |
42
|
|
|
public function __construct(string $personId = null, string $vehicleId = null, string $after = null, int $offset = null, int $limit = null) |
43
|
|
|
{ |
44
|
|
|
$this->personId = $personId; |
45
|
|
|
$this->vehicleId = $vehicleId; |
46
|
|
|
$this->after = $after; |
47
|
|
|
$this->offset = $offset; |
48
|
|
|
$this->limit = $limit; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return null|string |
53
|
|
|
*/ |
54
|
|
|
public function getPersonId(): ?string |
55
|
|
|
{ |
56
|
|
|
return $this->personId; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
|
|
public function hasPersonId(): bool |
63
|
|
|
{ |
64
|
|
|
return $this->personId !== null; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return null|string |
69
|
|
|
*/ |
70
|
|
|
public function getVehicleId(): ?string |
71
|
|
|
{ |
72
|
|
|
return $this->vehicleId; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return bool |
77
|
|
|
*/ |
78
|
|
|
public function hasVehicleId(): bool |
79
|
|
|
{ |
80
|
|
|
return $this->vehicleId !== null; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
|
|
public function hasAfter(): bool |
87
|
|
|
{ |
88
|
|
|
return $this->after !== null; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getAfter(): string |
95
|
|
|
{ |
96
|
|
|
return $this->after; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return bool |
101
|
|
|
*/ |
102
|
|
|
public function hasOffset(): bool |
103
|
|
|
{ |
104
|
|
|
return $this->offset !== null; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return int |
109
|
|
|
*/ |
110
|
|
|
public function getOffset(): int |
111
|
|
|
{ |
112
|
|
|
return $this->offset; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param int $offset |
117
|
|
|
* @return VehiclesQuery |
118
|
|
|
*/ |
119
|
|
|
public function setOffset(int $offset): VehiclesQuery |
120
|
|
|
{ |
121
|
|
|
$this->offset = $offset; |
122
|
|
|
|
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return bool |
128
|
|
|
*/ |
129
|
|
|
public function hasLimit(): bool |
130
|
|
|
{ |
131
|
|
|
return $this->limit !== null; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return int |
136
|
|
|
*/ |
137
|
|
|
public function getLimit(): int |
138
|
|
|
{ |
139
|
|
|
return $this->limit; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param int $limit |
144
|
|
|
* @return VehiclesQuery |
145
|
|
|
*/ |
146
|
|
|
public function setLimit(int $limit): VehiclesQuery |
147
|
|
|
{ |
148
|
|
|
$this->limit = $limit; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param Argument $argument |
155
|
|
|
* @return VehiclesQuery |
156
|
|
|
*/ |
157
|
|
|
public static function createFromArgument(Argument $argument): VehiclesQuery |
158
|
|
|
{ |
159
|
|
|
return new self( |
160
|
|
|
($argument->offsetGet('owner'))? AppGlobalId::getIdFromGlobalId($argument->offsetGet('owner')) : null, |
161
|
|
|
($argument->offsetGet('id'))? AppGlobalId::getIdFromGlobalId($argument->offsetGet('id')) : null, |
162
|
|
|
($argument->offsetGet('after'))? AppGlobalId::getIdFromGlobalId($argument->offsetGet('after')) : null |
163
|
|
|
); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|