Conditions | 1 |
Paths | 1 |
Total Lines | 129 |
Code Lines | 99 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 2 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
234 | #[ |
||
235 | Get( |
||
236 | path: "/posts/filters", |
||
237 | operationId: "postGetWithFilter", |
||
238 | description: "Get all posts with pagination (10 items per page by default, page 1 by default) |
||
239 | |||
240 | This API will get records from the database and return them as a paginated list. |
||
241 | The default number of items per page is 10 and the default page number is 1. You can change these values by passing the `per_page` and `page` query parameters. |
||
242 | ", |
||
243 | summary: "Get posts by filter with pagination", |
||
244 | tags: ["Post"], |
||
245 | parameters: [ |
||
246 | new Parameter( |
||
247 | name: 'categories', |
||
248 | description: 'Filter of items categories', |
||
249 | in: 'query', |
||
250 | required: false, |
||
251 | schema: new Schema(type: 'array', default: null) |
||
252 | ), |
||
253 | new Parameter( |
||
254 | name: 'categories_exclude', |
||
255 | description: 'Filter of items categories exclude', |
||
256 | in: 'query', |
||
257 | required: false, |
||
258 | schema: new Schema(type: 'array', default: null) |
||
259 | ), |
||
260 | new Parameter( |
||
261 | name: 'exclude', |
||
262 | description: 'Filter of items exclude', |
||
263 | in: 'query', |
||
264 | required: false, |
||
265 | schema: new Schema(type: 'array', default: null) |
||
266 | ), |
||
267 | new Parameter( |
||
268 | name: 'include', |
||
269 | description: 'Filter of items include', |
||
270 | in: 'query', |
||
271 | required: false, |
||
272 | schema: new Schema(type: 'array', default: null) |
||
273 | ), |
||
274 | new Parameter( |
||
275 | name: 'author', |
||
276 | description: 'Filter of items author', |
||
277 | in: 'query', |
||
278 | required: false, |
||
279 | schema: new Schema(type: 'array', default: null) |
||
280 | ), |
||
281 | new Parameter( |
||
282 | name: 'author_exclude', |
||
283 | description: 'Filter of items author exclude', |
||
284 | in: 'query', |
||
285 | required: false, |
||
286 | schema: new Schema(type: 'array', default: null) |
||
287 | ), |
||
288 | new Parameter( |
||
289 | name: 'featured', |
||
290 | description: 'Filter of items featured', |
||
291 | in: 'query', |
||
292 | required: false, |
||
293 | schema: new Schema(type: 'integer', default: null) |
||
294 | ), |
||
295 | new Parameter( |
||
296 | name: 'search', |
||
297 | description: 'Filter of items search in name and description', |
||
298 | in: 'query', |
||
299 | required: false, |
||
300 | schema: new Schema(type: 'string', default: null) |
||
301 | ), |
||
302 | new Parameter( |
||
303 | name: 'per_page', |
||
304 | description: 'Number of items per page', |
||
305 | in: 'query', |
||
306 | required: false, |
||
307 | schema: new Schema(type: 'integer', default: 10) |
||
308 | ), |
||
309 | new Parameter( |
||
310 | name: 'page', |
||
311 | description: 'Page number', |
||
312 | in: 'query', |
||
313 | required: false, |
||
314 | schema: new Schema(type: 'integer', default: 1) |
||
315 | ), |
||
316 | ], |
||
317 | responses: [ |
||
318 | new Response( |
||
319 | response: 200, |
||
320 | description: "Get posts successfully", |
||
321 | content: new JsonContent( |
||
322 | properties: [ |
||
323 | new Property( |
||
324 | property: 'error', |
||
325 | description: 'Error status', |
||
326 | type: 'boolean', |
||
327 | default: false |
||
328 | ), |
||
329 | new Property( |
||
330 | property: "data", |
||
331 | description: "Data of model", |
||
332 | type: "array", |
||
333 | items: new Items(ref: PostListResourceSchema::class) |
||
334 | ), |
||
335 | ] |
||
336 | ) |
||
337 | ), |
||
338 | new Response( |
||
339 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\BadRequestResponseSchema::class, |
||
340 | response: 400, |
||
341 | ), |
||
342 | new Response( |
||
343 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\ErrorNotFoundResponseSchema::class, |
||
344 | response: 404, |
||
345 | ), |
||
346 | new Response( |
||
347 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\InternalServerResponseSchema::class, |
||
348 | response: 500, |
||
349 | ), |
||
350 | ] |
||
351 | ) |
||
352 | ] |
||
353 | public function getFilters(Request $request): BaseHttpResponse|JsonResponse|JsonResource|RedirectResponse |
||
354 | { |
||
355 | $filters = FilterPost::setFilters($request->input()); |
||
356 | |||
357 | $data = $this->postRepository->getFilters((array) $filters); |
||
358 | |||
359 | return $this |
||
360 | ->httpResponse() |
||
361 | ->setData(ListPostResource::collection($data)) |
||
362 | ->toApiResponse(); |
||
363 | } |
||
365 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths