Conditions | 2 |
Paths | 1 |
Total Lines | 76 |
Code Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
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 |
||
40 | #[ |
||
41 | Get( |
||
42 | path: "/categories", |
||
43 | operationId: "categoryGetAllWithFilter", |
||
44 | description: "Get all categories with pagination (10 items per page by default, page 1 by default) |
||
45 | |||
46 | This API will get records from the database and return them as a paginated list. |
||
47 | 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. |
||
48 | ", |
||
49 | summary: "Get all categories with pagination", |
||
50 | security: [['sanctum' => []]], |
||
51 | tags: ["Category"], |
||
52 | parameters: [ |
||
53 | new Parameter( |
||
54 | name: 'per_page', |
||
55 | description: 'Number of items per page', |
||
56 | in: 'query', |
||
57 | required: false, |
||
58 | schema: new Schema(type: 'integer', default: 10) |
||
59 | ), |
||
60 | new Parameter( |
||
61 | name: 'page', |
||
62 | description: 'Page number', |
||
63 | in: 'query', |
||
64 | required: false, |
||
65 | schema: new Schema(type: 'integer', default: 1) |
||
66 | ), |
||
67 | ], |
||
68 | responses: [ |
||
69 | new Response( |
||
70 | response: 200, |
||
71 | description: "Get categories successfully", |
||
72 | content: new JsonContent( |
||
73 | properties: [ |
||
74 | new Property( |
||
75 | property: 'error', |
||
76 | description: 'Error status', |
||
77 | type: 'boolean', |
||
78 | default: false |
||
79 | ), |
||
80 | new Property( |
||
81 | property: "data", |
||
82 | description: "Data of model", |
||
83 | type: "array", |
||
84 | items: new Items(ref: CategoryListResourceSchema::class) |
||
85 | ), |
||
86 | ] |
||
87 | ) |
||
88 | ), |
||
89 | new Response( |
||
90 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\BadRequestResponseSchema::class, |
||
91 | response: 400, |
||
92 | ), |
||
93 | new Response( |
||
94 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\ErrorNotFoundResponseSchema::class, |
||
95 | response: 404, |
||
96 | ), |
||
97 | new Response( |
||
98 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\InternalServerResponseSchema::class, |
||
99 | response: 500, |
||
100 | ), |
||
101 | ] |
||
102 | ) |
||
103 | ] |
||
104 | public function index(Request $request): BaseHttpResponse|JsonResponse|JsonResource|RedirectResponse |
||
105 | { |
||
106 | $data = Category::query() |
||
107 | ->wherePublished() |
||
108 | ->orderByDesc('created_at') |
||
109 | ->with(['slugable']) |
||
110 | ->paginate($request->integer('per_page', 10) ?: 10); |
||
111 | |||
112 | return $this |
||
113 | ->httpResponse() |
||
114 | ->setData(ListCategoryResource::collection($data)) |
||
115 | ->toApiResponse(); |
||
116 | } |
||
219 |
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