1 | <?php |
||
25 | class QueryParameters implements EncodingParametersInterface |
||
26 | { |
||
27 | const INVALID_INCLUDE_PATHS = '9f4922b8-8e8b-4847-baf2-5831adfd6813'; |
||
28 | const INVALID_FIELD_SET = 'ec7d2c6b-97d1-4f94-ba94-d141d985fc6f'; |
||
29 | |||
30 | /** |
||
31 | * @var string[]|null |
||
32 | * @API\Property(path="[include]", parser="parseIncludePaths") |
||
33 | * @Assert\Type(type="array") |
||
34 | * @Assert\All({ |
||
35 | * @Assert\Type(type="string") |
||
36 | * }) |
||
37 | */ |
||
38 | protected $includePaths; |
||
39 | |||
40 | /** |
||
41 | * @var array[]|null |
||
42 | * @API\Property(path="[fields]", parser="parseFieldSets") |
||
43 | * @Assert\Type(type="array") |
||
44 | * @Assert\All({ |
||
45 | * @Assert\Type(type="array") |
||
46 | * }) |
||
47 | */ |
||
48 | protected $fieldSets; |
||
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | 4 | public function getIncludePaths() |
|
57 | |||
58 | /** |
||
59 | * Sets include paths |
||
60 | * |
||
61 | * @param string[]|null $paths |
||
62 | * @return $this |
||
63 | */ |
||
64 | 5 | public function setIncludePaths(array $paths = null) |
|
70 | |||
71 | /** |
||
72 | * @inheritdoc |
||
73 | */ |
||
74 | 2 | public function getFieldSets() |
|
78 | |||
79 | /** |
||
80 | * @inheritdoc |
||
81 | */ |
||
82 | 2 | public function getFieldSet($type) |
|
86 | |||
87 | /** |
||
88 | * @param array[]|null $fieldSets |
||
89 | * @return $this |
||
90 | */ |
||
91 | 4 | public function setFieldSets(array $fieldSets = null) |
|
97 | |||
98 | /** |
||
99 | * @inheritdoc |
||
100 | */ |
||
101 | 1 | public function getSortParameters() |
|
105 | |||
106 | /** |
||
107 | * @inheritdoc |
||
108 | */ |
||
109 | 1 | public function getPaginationParameters() |
|
113 | |||
114 | /** |
||
115 | * @inheritdoc |
||
116 | */ |
||
117 | 1 | public function getFilteringParameters() |
|
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | 1 | public function getUnrecognizedParameters() |
|
129 | |||
130 | /** |
||
131 | * @inheritdoc |
||
132 | */ |
||
133 | 1 | public function isEmpty() |
|
146 | |||
147 | /** |
||
148 | * Parse value of parameter that store include paths |
||
149 | * which should be included into response |
||
150 | * |
||
151 | * @param string|null $value |
||
152 | * @return array|null |
||
153 | */ |
||
154 | 4 | public function parseIncludePaths($value = null) { |
|
165 | |||
166 | /** |
||
167 | * Parse value of parameter that store fields which |
||
168 | * should be included into response |
||
169 | * |
||
170 | * @param array|null $value |
||
171 | * @return array|null |
||
172 | */ |
||
173 | 3 | public function parseFieldSets($value = null) { |
|
188 | |||
189 | /** |
||
190 | * Validate specified include paths |
||
191 | * |
||
192 | * @param ExecutionContextInterface $context |
||
193 | * @Assert\Callback() |
||
194 | */ |
||
195 | 1 | public function validateIncludePaths(ExecutionContextInterface $context) |
|
213 | |||
214 | /** |
||
215 | * Validate specified fields sets |
||
216 | * |
||
217 | * @param ExecutionContextInterface $context |
||
218 | * @Assert\Callback() |
||
219 | */ |
||
220 | 1 | public function validateFieldSets(ExecutionContextInterface $context) |
|
242 | |||
243 | /** |
||
244 | * Returns list of allowed include paths |
||
245 | * |
||
246 | * @return string[] |
||
247 | */ |
||
248 | 1 | protected function getAllowedIncludePaths() |
|
252 | |||
253 | /** |
||
254 | * Returns list of fields available in specified resource |
||
255 | * |
||
256 | * @param string $resource |
||
257 | * @return array[] |
||
258 | */ |
||
259 | 1 | protected function getAllowedFields($resource) |
|
266 | |||
267 | /** |
||
268 | * Add specified violation |
||
269 | * |
||
270 | * @param ExecutionContextInterface $context |
||
271 | * @param string $message |
||
272 | * @param array $params |
||
273 | * @param int $plural |
||
274 | * @param mixed $invalidValue |
||
275 | * @param string $code |
||
276 | * @param string $path |
||
277 | */ |
||
278 | 3 | protected function addViolation( |
|
300 | } |
||
301 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.