| Conditions | 7 |
| Paths | 5 |
| Total Lines | 62 |
| Code Lines | 34 |
| 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 |
||
| 49 | public function __invoke( |
||
| 50 | InputInterface $input, |
||
| 51 | OutputInterface $output, |
||
| 52 | #[Option(description: 'List all events available to replay', name: self::OPTION_LIST_EVENTS)] |
||
| 53 | bool $listEvents = false, |
||
| 54 | #[Option(description: 'List all projectors available for which events can be replayed', name: self::OPTION_LIST_PROJECTORS)] |
||
| 55 | bool $listProjectors = false, |
||
| 56 | ): int { |
||
| 57 | $availableEvents = $this->collection->getEventNames(); |
||
| 58 | $availableProjectors = $this->projectorCollection->getProjectorNames(); |
||
| 59 | |||
| 60 | if ($listEvents) { |
||
| 61 | $output->writeln('<info>The following events can be replayed:</info>'); |
||
| 62 | $output->writeln($availableEvents === [] ? 'None.' : $availableEvents); |
||
| 63 | |||
| 64 | return 0; |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($listProjectors) { |
||
| 68 | $output->writeln('<info>Events can be replayed for the following projectors:</info>'); |
||
| 69 | $output->writeln($availableProjectors === [] ? 'None.' : $availableProjectors); |
||
| 70 | |||
| 71 | return 0; |
||
| 72 | } |
||
| 73 | |||
| 74 | if ($availableProjectors === []) { |
||
| 75 | $output->writeln('<error>There are no projectors configured to replay events for</error>'); |
||
| 76 | |||
| 77 | return 1; |
||
| 78 | } |
||
| 79 | |||
| 80 | $questionHelper = new QuestionHelper(); |
||
| 81 | |||
| 82 | $selectEventsQuestion = new ChoiceQuestion( |
||
| 83 | 'Which events would you like to replay? Please supply a comma-separated list of numbers.', |
||
| 84 | $availableEvents, |
||
| 85 | ); |
||
| 86 | $selectEventsQuestion->setMultiselect(true); |
||
| 87 | |||
| 88 | $chosenEvents = $questionHelper->ask($input, $output, $selectEventsQuestion); |
||
| 89 | $eventSelection = $this->collection->select($chosenEvents); |
||
| 90 | |||
| 91 | $selectProjectorsQuestion = new ChoiceQuestion( |
||
| 92 | 'For which projectors would you like to replay the selected events? ' |
||
| 93 | . 'Please supply a comma-separated list of numbers.', |
||
| 94 | $availableProjectors, |
||
| 95 | ); |
||
| 96 | $selectProjectorsQuestion->setMultiselect(true); |
||
| 97 | |||
| 98 | $chosenProjectors = $questionHelper->ask($input, $output, $selectProjectorsQuestion); |
||
| 99 | $projectorSelection = $this->projectorCollection->selectByNames($chosenProjectors); |
||
| 100 | |||
| 101 | $events = $this->pastEventsService->findEventsBy($eventSelection); |
||
| 102 | |||
| 103 | $output->writeln('<info>Registering projectors</info>'); |
||
| 104 | foreach ($projectorSelection as $projector) { |
||
| 105 | $this->eventDispatcher->registerProjector($projector); |
||
| 106 | } |
||
| 107 | |||
| 108 | $output->writeln('<info>Dispatching events</info>'); |
||
| 109 | $this->eventDispatcher->dispatch($events); |
||
| 110 | return 0; |
||
| 111 | } |
||
| 113 |
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