| Conditions | 8 |
| Paths | 27 |
| Total Lines | 115 |
| Code Lines | 79 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 46 | public function __invoke( |
||
| 47 | #[Argument(description: 'The NameID of the identity to create', name: 'name-id')] |
||
| 48 | string $nameId, |
||
| 49 | #[Argument(description: 'The institution of the identity to create', name: 'institution')] |
||
| 50 | string $institution, |
||
| 51 | #[Argument(description: 'The GSSP token type as defined in the GSSP config, for example tiqr or webauthn', name: 'gssp-token-type')] |
||
| 52 | string $gsspTokenType, |
||
| 53 | #[Argument(description: 'The identifier of the token as registered at the GSSP', name: 'gssp-token-identifier')] |
||
| 54 | string $gsspTokenIdentifier, |
||
| 55 | #[Argument(description: 'Valid arguments: unverified, verified, vetted', name: 'registration-status')] |
||
| 56 | string $registrationStatus, |
||
| 57 | #[Argument(description: 'The id of the vetting actor', name: 'actor-id')] |
||
| 58 | string $actorId, |
||
| 59 | OutputInterface $output |
||
| 60 | ): int { |
||
| 61 | $this->bootstrapService->validRegistrationStatus($registrationStatus); |
||
| 62 | |||
| 63 | $nameId = new NameId($nameId); |
||
| 64 | $institutionText = $institution; |
||
| 65 | $institution = new Institution($institutionText); |
||
| 66 | $mailVerificationRequired = $this->bootstrapService->requiresMailVerification($institutionText); |
||
| 67 | $tokenType = $gsspTokenType; |
||
| 68 | $tokenIdentifier = $gsspTokenIdentifier; |
||
| 69 | |||
| 70 | $this->bootstrapService->enrichEventMetadata($actorId); |
||
| 71 | if (!$this->bootstrapService->identityExists($nameId, $institution)) { |
||
| 72 | $output->writeln( |
||
| 73 | sprintf( |
||
| 74 | '<error>An identity with name ID "%s" from institution "%s" does not exist, create it first.</error>', |
||
| 75 | $nameId->getNameId(), |
||
| 76 | $institution->getInstitution(), |
||
| 77 | ), |
||
| 78 | ); |
||
| 79 | |||
| 80 | return 1; |
||
| 81 | } |
||
| 82 | $identity = $this->bootstrapService->getIdentity($nameId, $institution); |
||
| 83 | $output->writeln( |
||
| 84 | sprintf( |
||
| 85 | '<comment>Adding a %s %s GSSP token for %s</comment>', |
||
| 86 | $registrationStatus, |
||
| 87 | $tokenType, |
||
| 88 | $identity->commonName, |
||
| 89 | ), |
||
| 90 | ); |
||
| 91 | $this->transactionHelper->beginTransaction(); |
||
| 92 | $secondFactorId = Uuid::uuid4()->toString(); |
||
| 93 | |||
| 94 | try { |
||
| 95 | switch ($registrationStatus) { |
||
| 96 | case "unverified": |
||
| 97 | $output->writeln(sprintf('<comment>Creating an unverified %s token</comment>', $tokenType)); |
||
| 98 | $this->bootstrapService->proveGsspPossession( |
||
| 99 | $secondFactorId, |
||
| 100 | $identity, |
||
| 101 | $tokenType, |
||
| 102 | $tokenIdentifier, |
||
| 103 | ); |
||
| 104 | break; |
||
| 105 | case "verified": |
||
| 106 | $output->writeln(sprintf('<comment>Creating an unverified %s token</comment>', $tokenType)); |
||
| 107 | $this->bootstrapService->proveGsspPossession( |
||
| 108 | $secondFactorId, |
||
| 109 | $identity, |
||
| 110 | $tokenType, |
||
| 111 | $tokenIdentifier, |
||
| 112 | ); |
||
| 113 | if ($mailVerificationRequired) { |
||
| 114 | $output->writeln(sprintf('<comment>Creating an verified %s token</comment>', $tokenType)); |
||
| 115 | $this->bootstrapService->verifyEmail($identity, $tokenType); |
||
| 116 | } |
||
| 117 | break; |
||
| 118 | case "vetted": |
||
| 119 | $output->writeln(sprintf('<comment>Creating an unverified %s token</comment>', $tokenType)); |
||
| 120 | $this->bootstrapService->proveGsspPossession( |
||
| 121 | $secondFactorId, |
||
| 122 | $identity, |
||
| 123 | $tokenType, |
||
| 124 | $tokenIdentifier, |
||
| 125 | ); |
||
| 126 | if ($mailVerificationRequired) { |
||
| 127 | $output->writeln(sprintf('<comment>Creating an verified %s token</comment>', $tokenType)); |
||
| 128 | $this->bootstrapService->verifyEmail($identity, $tokenType); |
||
| 129 | } |
||
| 130 | $output->writeln(sprintf('<comment>Vetting the verified %s token</comment>', $tokenType)); |
||
| 131 | $this->bootstrapService->vetSecondFactor( |
||
| 132 | $tokenType, |
||
| 133 | $actorId, |
||
| 134 | $identity, |
||
| 135 | $secondFactorId, |
||
| 136 | $tokenIdentifier, |
||
| 137 | ); |
||
| 138 | break; |
||
| 139 | } |
||
| 140 | $this->transactionHelper->finishTransaction(); |
||
| 141 | } catch (Exception $e) { |
||
| 142 | $output->writeln( |
||
| 143 | sprintf( |
||
| 144 | '<error>An Error occurred when trying to bootstrap the %s token: "%s"</error>', |
||
| 145 | $tokenType, |
||
| 146 | $e->getMessage(), |
||
| 147 | ), |
||
| 148 | ); |
||
| 149 | $this->transactionHelper->rollback(); |
||
| 150 | return 1; |
||
| 151 | } |
||
| 152 | $output->writeln( |
||
| 153 | sprintf( |
||
| 154 | '<info>Successfully %s %s second factor with UUID %s</info>', |
||
| 155 | $registrationStatus, |
||
| 156 | $tokenType, |
||
| 157 | $secondFactorId, |
||
| 158 | ), |
||
| 159 | ); |
||
| 160 | return 0; |
||
| 161 | } |
||
| 163 |
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