Conditions | 6 |
Paths | 44 |
Total Lines | 51 |
Code Lines | 34 |
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 |
||
29 | public function __invoke(): JsonResponse |
||
30 | { |
||
31 | |||
32 | try { |
||
33 | |||
34 | |||
35 | $defaultCompany = []; |
||
36 | $configs = []; |
||
37 | $allConfigs = []; |
||
38 | $token = $this->security->getToken(); |
||
39 | $user = $token ? $token->getUser() : null; |
||
40 | |||
41 | $permissions = $user ? $this->roles->getAllRoles($this->company) : ['guest']; |
||
42 | |||
43 | if ($this->company) { |
||
44 | $allConfigs = $this->em->getRepository(Config::class)->findBy([ |
||
45 | 'people' => $this->company->getId(), |
||
46 | 'visibility' => 'public' |
||
47 | ]); |
||
48 | |||
49 | foreach ($allConfigs as $config) { |
||
50 | $configs[$config->getConfigKey()] = $config->getConfigValue(); |
||
51 | } |
||
52 | |||
53 | $defaultCompany = [ |
||
54 | 'id' => $this->company->getId(), |
||
55 | 'alias' => $this->company->getAlias(), |
||
56 | 'configs' => $configs, |
||
57 | 'domainType' => $this->domainService->getPeopleDomain()->getDomainType(), |
||
58 | 'permissions' => $permissions, |
||
59 | 'theme' => $this->getTheme(), |
||
60 | 'logo' => $this->fileService->getFileUrl($this->company) |
||
61 | ]; |
||
62 | } |
||
63 | |||
64 | return new JsonResponse([ |
||
65 | 'response' => [ |
||
66 | 'data' => $defaultCompany, |
||
67 | 'count' => 1, |
||
68 | 'error' => '', |
||
69 | 'success' => true |
||
70 | ], |
||
71 | ]); |
||
72 | } catch (\Exception $e) { |
||
73 | |||
74 | return new JsonResponse([ |
||
75 | 'response' => [ |
||
76 | 'data' => [], |
||
77 | 'count' => 0, |
||
78 | 'error' => $e->getMessage(), |
||
79 | 'success' => false, |
||
80 | ], |
||
98 |
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