| Conditions | 5 |
| Paths | 33 |
| Total Lines | 61 |
| Code Lines | 37 |
| 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 |
||
| 61 | if ($sourceIdentity === null) { |
||
| 62 | throw new InvalidArgumentException("oldNameId could net be resolved to a Identity."); |
||
| 63 | } |
||
| 64 | |||
| 65 | $targetIdentity = $this->bootstrapService->getIdentityByNameId($targetNameId); |
||
| 66 | |||
| 67 | try { |
||
| 68 | $this->transactionHelper->beginTransaction(); |
||
| 69 | |||
| 70 | // Check if target identity should be created |
||
| 71 | if (!$targetIdentity instanceof Identity) { |
||
| 72 | $output->writeln( |
||
| 73 | sprintf('<info>Target with NameID %s does not exist, creating new identity</info>', $targetNameId), |
||
| 74 | ); |
||
| 75 | |||
| 76 | $identityId = $this->createIdentity($targetNameId, $sourceIdentity, $targetInstitution, $email); |
||
| 77 | |||
| 78 | $output->writeln( |
||
| 79 | sprintf('<info>Successfully created identity with UUID %s</info>', $identityId), |
||
| 80 | ); |
||
| 81 | |||
| 82 | |||
| 83 | $targetIdentity = $this->bootstrapService->getIdentityByNameId($targetNameId); |
||
| 84 | } |
||
| 85 | |||
| 86 | // Foreach token, perform the token move command |
||
| 87 | $sourceVettedSecondFactors = $this->bootstrapService->getVettedSecondFactorsFromIdentity($sourceIdentity); |
||
| 88 | $targetVettedSecondFactors = $this->bootstrapService->getVettedSecondFactorsFromIdentity($targetIdentity); |
||
| 89 | foreach ($sourceVettedSecondFactors as $secondFactor) { |
||
| 90 | if (!$this->tokenExists($targetVettedSecondFactors, $secondFactor)) { |
||
| 91 | $this->bootstrapService->migrateVettedSecondFactor($sourceIdentity, $targetIdentity, $secondFactor); |
||
| 92 | $output->writeln(sprintf('<comment>Moved token %s</comment>', $secondFactor->id)); |
||
| 93 | } else { |
||
| 94 | $output->writeln( |
||
| 95 | sprintf('<info>Skipped moving token %s, already present"</info>', $secondFactor->id), |
||
| 96 | ); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->transactionHelper->finishTransaction(); |
||
| 101 | } catch (Exception $e) { |
||
| 102 | $output->writeln( |
||
| 103 | sprintf( |
||
| 104 | '<error>An Error occurred when trying to move the tokens of identity: "%s"</error>', |
||
| 105 | $e->getMessage(), |
||
| 106 | ), |
||
| 107 | ); |
||
| 108 | $this->transactionHelper->rollback(); |
||
| 109 | return 1; |
||
| 110 | } |
||
| 111 | $output->writeln( |
||
| 112 | sprintf( |
||
| 113 | '<info>Successfully moved tokens from identity %s to identity %s</info>', |
||
| 114 | $sourceIdentity->id, |
||
| 115 | $targetIdentity->id, |
||
| 116 | ), |
||
| 117 | ); |
||
| 118 | return 0; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @return string |
||
| 153 |
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