| Conditions | 3 |
| Paths | 6 |
| Total Lines | 58 |
| Code Lines | 32 |
| 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 |
||
| 37 | public function __invoke( |
||
| 38 | #[Argument(description: 'The NameID of the identity to create', name: 'name-id')] |
||
| 39 | string $nameId, |
||
| 40 | #[Argument(description: 'The institution of the identity to create', name: 'institution')] |
||
| 41 | string $institution, |
||
| 42 | #[Argument(description: 'The Common Name of the identity to create', name: 'common-name')] |
||
| 43 | string $commonName, |
||
| 44 | #[Argument(description: 'The e-mail address of the identity to create', name: 'email')] |
||
| 45 | string $email, |
||
| 46 | #[Argument(description: 'The preferred locale of the identity to create', name: 'preferred-locale')] |
||
| 47 | string $preferredLocale, |
||
| 48 | #[Argument(description: 'The id of the vetting actor', name: 'actor-id')] |
||
| 49 | string $actorId, |
||
| 50 | OutputInterface $output |
||
| 51 | ): int { |
||
| 52 | $nameId = new NameId($nameId); |
||
| 53 | $institutionText = $institution; |
||
| 54 | $institution = new Institution($institutionText); |
||
| 55 | |||
| 56 | $this->bootstrapService->enrichEventMetadata($actorId); |
||
| 57 | |||
| 58 | $output->writeln(sprintf('<comment>Adding an identity named: %s</comment>', $commonName)); |
||
| 59 | if ($this->bootstrapService->identityExists($nameId, $institution)) { |
||
| 60 | $output->writeln( |
||
| 61 | sprintf( |
||
| 62 | '<error>An identity with name ID "%s" from institution "%s" already exists</error>', |
||
| 63 | $nameId->getNameId(), |
||
| 64 | $institution->getInstitution(), |
||
| 65 | ), |
||
| 66 | ); |
||
| 67 | return 1; |
||
| 68 | } |
||
| 69 | try { |
||
| 70 | $this->transactionHelper->beginTransaction(); |
||
| 71 | $output->writeln('<info>Creating a new identity</info>'); |
||
| 72 | $identity = $this->bootstrapService->createIdentity( |
||
| 73 | $institution, |
||
| 74 | $nameId, |
||
| 75 | $commonName, |
||
| 76 | $email, |
||
| 77 | $preferredLocale, |
||
| 78 | ); |
||
| 79 | $this->transactionHelper->finishTransaction(); |
||
| 80 | } catch (Exception $e) { |
||
| 81 | $output->writeln( |
||
| 82 | sprintf( |
||
| 83 | '<error>An Error occurred when trying to bootstrap the identity: "%s"</error>', |
||
| 84 | $e->getMessage(), |
||
| 85 | ), |
||
| 86 | ); |
||
| 87 | $this->transactionHelper->rollback(); |
||
| 88 | return 1; |
||
| 89 | } |
||
| 90 | $output->writeln( |
||
| 91 | sprintf('<info>Successfully created identity with UUID %s</info>', $identity->id), |
||
| 92 | ); |
||
| 93 | |||
| 94 | return 0; |
||
| 95 | } |
||
| 97 |
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