| Conditions | 3 |
| Paths | 4 |
| Total Lines | 67 |
| Code Lines | 36 |
| 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 Common Name of the identity to create', name: 'common-name')] |
||
| 52 | string $commonName, |
||
| 53 | #[Argument(description: 'The e-mail address of the identity to create', name: 'email')] |
||
| 54 | string $email, |
||
| 55 | #[Argument(description: 'The preferred locale of the identity to create', name: 'preferred-locale')] |
||
| 56 | string $preferredLocale, |
||
| 57 | #[Argument(description: 'The public ID of the Yubikey. Remove the last 32 characters of a Yubikey OTP to acquire this.', name: 'yubikey')] |
||
| 58 | string $yubikey, |
||
| 59 | OutputInterface $output |
||
| 60 | ): int { |
||
| 61 | $nameId = new NameId($nameId); |
||
| 62 | $institution = new Institution($institution); |
||
| 63 | |||
| 64 | if ($this->projectionRepository->hasIdentityWithNameIdAndInstitution($nameId, $institution)) { |
||
| 65 | $output->writeln( |
||
| 66 | sprintf( |
||
| 67 | '<error>An identity with name ID "%s" from institution "%s" already exists</error>', |
||
| 68 | $nameId->getNameId(), |
||
| 69 | $institution->getInstitution(), |
||
| 70 | ), |
||
| 71 | ); |
||
| 72 | |||
| 73 | return 1; |
||
| 74 | } |
||
| 75 | |||
| 76 | $command = new BootstrapIdentityWithYubikeySecondFactorIdentityCommand(); |
||
| 77 | $command->UUID = (string)Uuid::uuid4(); |
||
| 78 | $command->identityId = (string)Uuid::uuid4(); |
||
| 79 | $command->nameId = $nameId; |
||
| 80 | $command->institution = $institution; |
||
| 81 | $command->commonName = $commonName; |
||
| 82 | $command->email = $email; |
||
| 83 | $command->preferredLocale = $preferredLocale; |
||
| 84 | $secondFactorId = (string)Uuid::uuid4(); |
||
| 85 | $command->secondFactorId = $secondFactorId; |
||
| 86 | $command->yubikeyPublicId = $yubikey; |
||
| 87 | |||
| 88 | $this->transactionHelper->beginTransaction(); |
||
| 89 | |||
| 90 | try { |
||
| 91 | $command = $this->transactionHelper->process($command); |
||
| 92 | $this->transactionHelper->finishTransaction(); |
||
| 93 | } catch (Exception $e) { |
||
| 94 | $output->writeln( |
||
| 95 | sprintf( |
||
| 96 | '<error>An Error occurred when trying to bootstrap the token for identity: "%s"</error>', |
||
| 97 | $e->getMessage(), |
||
| 98 | ), |
||
| 99 | ); |
||
| 100 | |||
| 101 | $this->transactionHelper->rollBack(); |
||
| 102 | |||
| 103 | throw $e; |
||
| 104 | } |
||
| 105 | |||
| 106 | $output->writeln( |
||
| 107 | sprintf( |
||
| 108 | '<info>Successfully registered a Yubikey token with UUID %s</info>', |
||
| 109 | $secondFactorId, |
||
| 110 | ), |
||
| 111 | ); |
||
| 112 | return 0; |
||
| 113 | } |
||
| 115 |
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