| Conditions | 18 |
| Paths | 29 |
| Total Lines | 50 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 342 |
| 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 |
||
| 18 | #[Override] |
||
| 19 | public function checkPrivilegeFor(int $stationId, UserInterface|ShipInterface $source): bool |
||
| 20 | { |
||
| 21 | $privileges = $this->dockingPrivilegeRepository->getByStation($stationId); |
||
| 22 | if ($privileges === []) { |
||
| 23 | return false; |
||
| 24 | } |
||
| 25 | |||
| 26 | $allowed = false; |
||
| 27 | $user = $source instanceof UserInterface ? $source : $source->getUser(); |
||
| 28 | foreach ($privileges as $priv) { |
||
| 29 | switch ($priv->getPrivilegeType()) { |
||
| 30 | case DockTypeEnum::USER: |
||
| 31 | if ($priv->getTargetId() === $user->getId()) { |
||
| 32 | if ($priv->getPrivilegeMode() == DockModeEnum::DENY) { |
||
| 33 | return false; |
||
| 34 | } |
||
| 35 | $allowed = true; |
||
| 36 | } |
||
| 37 | break; |
||
| 38 | case DockTypeEnum::ALLIANCE: |
||
| 39 | if ($user->getAlliance() !== null && $priv->getTargetId() === $user->getAlliance()->getId()) { |
||
| 40 | if ($priv->getPrivilegeMode() == DockModeEnum::DENY) { |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | $allowed = true; |
||
| 44 | } |
||
| 45 | break; |
||
| 46 | case DockTypeEnum::FACTION: |
||
| 47 | if ($priv->getTargetId() == $user->getFactionId()) { |
||
| 48 | if ($priv->getPrivilegeMode() == DockModeEnum::DENY) { |
||
| 49 | return false; |
||
| 50 | } |
||
| 51 | $allowed = true; |
||
| 52 | } |
||
| 53 | break; |
||
| 54 | case DockTypeEnum::SHIP: |
||
| 55 | if ( |
||
| 56 | $source instanceof ShipInterface |
||
| 57 | && $priv->getTargetId() == $source->getId() |
||
| 58 | ) { |
||
| 59 | if ($priv->getPrivilegeMode() == DockModeEnum::DENY) { |
||
| 60 | return false; |
||
| 61 | } |
||
| 62 | $allowed = true; |
||
| 63 | } |
||
| 64 | break; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | return $allowed; |
||
| 68 | } |
||
| 70 |
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