| Conditions | 11 |
| Paths | 48 |
| Total Lines | 77 |
| Code Lines | 41 |
| 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 |
||
| 82 | public function getAllRolesByCompany(People $people, People $company): array |
||
| 83 | { |
||
| 84 | $peopleRole = []; |
||
| 85 | $mainCompany = $this->getMainCompany(); |
||
| 86 | |||
| 87 | if ($company->getId() == $mainCompany->getId()) { |
||
| 88 | $isSuper = $mainCompany->getCompany() |
||
| 89 | ->exists( |
||
| 90 | function ($key, PeopleLink $peopleLink) use ($people) { |
||
| 91 | return $peopleLink->getPeople()->getId() === $people->getId(); |
||
| 92 | } |
||
| 93 | ); |
||
| 94 | |||
| 95 | if ($isSuper) { |
||
| 96 | $peopleRole[] = 'super'; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | $peopleFranchisee = $this->manager->getRepository(People::class)->getPeopleLink($mainCompany, 'franchisee'); |
||
| 101 | |||
| 102 | $isFranchisee = $mainCompany->getCompany() |
||
| 103 | ->exists( |
||
| 104 | function ($key, PeopleLink $peopleFranchisee) use ($people, $company) { |
||
| 105 | foreach ($peopleFranchisee->getCompany() as $peopleLink) { |
||
| 106 | if ($peopleLink->getCompany()->getId() == $company->getId() && $peopleLink->getPeople()->getId() === $people->getId()) { |
||
| 107 | return true; |
||
| 108 | } |
||
| 109 | } |
||
| 110 | } |
||
| 111 | ); |
||
| 112 | $peopleRole[] = 'franchisee'; |
||
| 113 | if ($isFranchisee) { |
||
| 114 | $peopleRole[] = 'franchisee'; |
||
| 115 | $peopleRole[] = 'admin'; |
||
| 116 | } |
||
| 117 | |||
| 118 | $isClient = $company->getCompany() |
||
| 119 | ->exists( |
||
| 120 | function ($key, PeopleLink $peopleLink) use ($people) { |
||
| 121 | return $peopleLink->getPeople()->getId() === $people->getId(); |
||
| 122 | } |
||
| 123 | ); |
||
| 124 | |||
| 125 | if ($isClient) { |
||
| 126 | $peopleRole[] = 'client'; |
||
| 127 | } |
||
| 128 | |||
| 129 | |||
| 130 | $isClient = $people->getLink() |
||
| 131 | ->exists( |
||
| 132 | function ($key, PeopleLink $peopleLink) use ($company) { |
||
| 133 | return $this->manager->getRepository(PeopleClient::class)->findOneBy( |
||
| 134 | [ |
||
| 135 | 'client' => $peopleLink->getCompany(), |
||
| 136 | 'company_id' => $company->getId() |
||
| 137 | ] |
||
| 138 | ); |
||
| 139 | } |
||
| 140 | ); |
||
| 141 | |||
| 142 | if ($isClient) { |
||
| 143 | $peopleRole[] = 'client'; |
||
| 144 | } |
||
| 145 | |||
| 146 | |||
| 147 | $isSalesman = $company->getPeopleSalesman() |
||
| 148 | ->exists( |
||
| 149 | function ($key, PeopleSalesman $peopleSalesman) use ($people) { |
||
| 150 | return $peopleSalesman->getSalesman()->getId() === $people->getId(); |
||
| 151 | } |
||
| 152 | ); |
||
| 153 | if ($isSalesman) { |
||
| 154 | $peopleRole[] = 'salesman'; |
||
| 155 | } |
||
| 156 | |||
| 157 | |||
| 158 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
||
| 159 | } |
||
| 179 |
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