Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
19 | #[ |
||
20 | PostAttribute( |
||
21 | path: "/posts/{id}/increment-views", |
||
22 | operationId: "incrementViewCountPostById", |
||
23 | description: "Increment views count of the post by ID. Only adds 1 view per IP in 1 hour.", |
||
24 | summary: "Increment views count of the post by ID", |
||
25 | tags: ["Post"], |
||
26 | parameters: [ |
||
27 | new Parameter( |
||
28 | name: 'id', |
||
29 | description: 'Post Id', |
||
30 | in: 'path', |
||
31 | required: true, |
||
32 | schema: new Schema(type: 'integer', example: 1) |
||
33 | ), |
||
34 | ], |
||
35 | responses: [ |
||
36 | new Response( |
||
37 | response: 200, |
||
38 | description: "Success", |
||
39 | content: new JsonContent( |
||
40 | properties: [ |
||
41 | new Property( |
||
42 | property: 'error', |
||
43 | description: 'Error status', |
||
44 | type: 'boolean', |
||
45 | default: false |
||
46 | ), |
||
47 | new Property( |
||
48 | property: "data", |
||
49 | ref: ViewCountResourceSchema::class, |
||
50 | description: "Updated view count data", |
||
51 | type: "object", |
||
52 | ), |
||
53 | ] |
||
54 | ) |
||
55 | ), |
||
56 | new Response( |
||
57 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\BadRequestResponseSchema::class, |
||
58 | response: 400, |
||
59 | ), |
||
60 | new Response( |
||
61 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\ErrorNotFoundResponseSchema::class, |
||
62 | response: 404, |
||
63 | ), |
||
64 | new Response( |
||
65 | ref: \CSlant\Blog\Api\OpenApi\Responses\Errors\InternalServerResponseSchema::class, |
||
66 | response: 500, |
||
67 | ), |
||
68 | ] |
||
69 | ) |
||
70 | ] |
||
71 | public function __invoke(Request $request, int $id): BaseHttpResponse|JsonResponse|JsonResource|RedirectResponse |
||
72 | { |
||
73 | $post = Post::findOrFail($id); |
||
74 | |||
75 | return $this |
||
76 | ->httpResponse() |
||
77 | ->setData(new ViewCountResource($post)) |
||
78 | ->toApiResponse(); |
||
79 | } |
||
81 |
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