| Conditions | 6 |
| Paths | 36 |
| Total Lines | 60 |
| Code Lines | 40 |
| 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 |
||
| 33 | public function __invoke(Request $request): JsonResponse |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * @var string $domain |
||
| 37 | */ |
||
| 38 | $domain = $request->get('app-domain', null); |
||
| 39 | |||
| 40 | try { |
||
| 41 | |||
| 42 | $this->domain = $this->getDomain($domain); |
||
| 43 | $this->getCompany(); |
||
| 44 | |||
| 45 | $defaultCompany = []; |
||
| 46 | $configs = []; |
||
| 47 | $allConfigs = []; |
||
| 48 | $user = $this->security->getUser(); |
||
| 49 | |||
| 50 | $permissions = $user ? $this->roles->getAllRoles($user->getPeople()) : ['guest']; |
||
| 51 | |||
| 52 | if ($this->company) { |
||
| 53 | $allConfigs = $this->em->getRepository(Config::class)->findBy([ |
||
| 54 | 'people' => $this->company->getPeople()->getId(), |
||
| 55 | 'visibility' => 'public' |
||
| 56 | ]); |
||
| 57 | |||
| 58 | foreach ($allConfigs as $config) { |
||
| 59 | $configs[$config->getConfigKey()] = $config->getConfigValue(); |
||
| 60 | } |
||
| 61 | |||
| 62 | $defaultCompany = [ |
||
| 63 | 'id' => $this->company->getPeople()->getId(), |
||
| 64 | 'alias' => $this->company->getPeople()->getAlias(), |
||
| 65 | 'configs' => $configs, |
||
| 66 | 'domainType' => $this->company->getDomainType(), |
||
| 67 | 'permissions' => $permissions, |
||
| 68 | 'theme' => $this->getTheme(), |
||
| 69 | 'logo' => $this->company->getPeople()->getFile() ? [ |
||
| 70 | 'id' => $this->company->getPeople()->getFile()->getId(), |
||
| 71 | 'domain' => $_SERVER['HTTP_HOST'], |
||
| 72 | 'url' => '/files/download/' . $this->company->getPeople()->getFile()->getId() |
||
| 73 | ] : null, |
||
| 74 | ]; |
||
| 75 | } |
||
| 76 | |||
| 77 | return new JsonResponse([ |
||
| 78 | 'response' => [ |
||
| 79 | 'data' => $defaultCompany, |
||
| 80 | 'count' => 1, |
||
| 81 | 'error' => '', |
||
| 82 | 'success' => true |
||
| 83 | ], |
||
| 84 | ]); |
||
| 85 | } catch (\Exception $e) { |
||
| 86 | |||
| 87 | return new JsonResponse([ |
||
| 88 | 'response' => [ |
||
| 89 | 'data' => [], |
||
| 90 | 'count' => 0, |
||
| 91 | 'error' => $e->getMessage(), |
||
| 92 | 'success' => false, |
||
| 93 | ], |
||
| 120 |
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