Conditions | 6 |
Paths | 70 |
Total Lines | 55 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
32 | protected function returnAction(Request $request): JsonResponse |
||
33 | { |
||
34 | try { |
||
35 | |||
36 | |||
37 | if ($request->get('code')) |
||
38 | $token = $this->provider->getAccessToken('authorization_code', [ |
||
39 | 'code' => $request->get('code') |
||
40 | ]); |
||
41 | |||
42 | if ($request->get('access_token')) |
||
43 | $token = new AccessToken([ |
||
44 | 'access_token' => $request->get('access_token'), |
||
45 | ]); |
||
46 | |||
47 | if ($request->get('code')) |
||
48 | $token = $this->provider->getAccessToken('authorization_code', [ |
||
49 | 'code' => $request->get('code') |
||
50 | ]); |
||
51 | |||
52 | $ownerDetails = $this->provider->getResourceOwner($token); |
||
53 | |||
54 | $user = $this->userService->discoveryUser($ownerDetails->getEmail(), md5(microtime()), $ownerDetails->getFirstName(), $ownerDetails->getLasttName()); |
||
55 | |||
56 | $data = [ |
||
57 | 'id' => $user->getPeople()->getId(), |
||
58 | 'username' => $user->getUsername(), |
||
59 | 'roles' => $user->getRoles(), |
||
60 | 'api_key' => $user->getApiKey(), |
||
61 | 'people' => $user->getPeople()->getId(), |
||
62 | 'mycompany' => $this->userService->getCompanyId($user), |
||
63 | 'realname' => $ownerDetails->getFirstName(), |
||
64 | 'avatar' => $user->getPeople()->getImage() ? '/files/' . $user->getPeople()->getImage()->getId() . '/download' : null, |
||
65 | 'email' => $ownerDetails->getEmail(), |
||
66 | 'active' => (int) $user->getPeople()->getEnabled(), |
||
67 | ]; |
||
68 | |||
69 | |||
70 | |||
71 | return new JsonResponse([ |
||
72 | 'response' => [ |
||
73 | 'data' => $data, |
||
74 | 'count' => 1, |
||
75 | 'error' => '', |
||
76 | 'success' => true, |
||
77 | ], |
||
78 | ]); |
||
79 | } catch (Exception $e) { |
||
80 | |||
81 | return new JsonResponse([ |
||
82 | 'response' => [ |
||
83 | 'data' => [], |
||
84 | 'count' => 0, |
||
85 | 'error' => $e->getMessage(), |
||
86 | 'success' => false, |
||
87 | ], |
||
94 |
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