| Conditions | 12 |
| Paths | 10 |
| Total Lines | 71 |
| Code Lines | 38 |
| 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 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 50 | { |
||
| 51 | $io = new SymfonyStyle(input: $input, output: $output); |
||
| 52 | |||
| 53 | $name = $this->stringArgument(input: $input, name: 'name'); |
||
| 54 | $title = $this->stringOption(input: $input, name: 'title'); |
||
| 55 | $create = $this->boolOption(input: $input, name: 'create'); |
||
| 56 | $delete = $this->boolOption(input: $input, name: 'delete'); |
||
| 57 | |||
| 58 | if ($name === '') { |
||
| 59 | $io->error(message: 'The tree name cannot be empty.'); |
||
| 60 | |||
| 61 | return Command::INVALID; |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($delete && $create) { |
||
| 65 | $io->error(message: 'Invalid options: cannot use --delete and --create at the same time.'); |
||
| 66 | |||
| 67 | return Command::INVALID; |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($delete && $title !== '') { |
||
| 71 | $io->error(message: 'Invalid options: cannot use --delete and --title at the same time.'); |
||
| 72 | |||
| 73 | return Command::INVALID; |
||
| 74 | } |
||
| 75 | |||
| 76 | $tree = $this->tree_service->all()->get('name'); |
||
| 77 | |||
| 78 | if ($create) { |
||
| 79 | if ($tree instanceof Tree) { |
||
| 80 | $io->error(message: 'A tree with the name "' . $name . '" already exists.'); |
||
| 81 | |||
| 82 | return Command::FAILURE; |
||
| 83 | } |
||
| 84 | |||
| 85 | if ($title === '') { |
||
| 86 | $io->error(message: 'Invalid options: --title is required when using --create.'); |
||
| 87 | |||
| 88 | return Command::FAILURE; |
||
| 89 | } |
||
| 90 | |||
| 91 | $this->tree_service->create(name: $name, title: $title); |
||
| 92 | $io->info(message: 'Tree ‘' . $name . '’ was created with title ‘' . $title . '’.'); |
||
| 93 | |||
| 94 | return self::SUCCESS; |
||
| 95 | } |
||
| 96 | |||
| 97 | if ($tree === null) { |
||
| 98 | $io->error(message: 'Tree ‘' . $name . '’ does not exist.'); |
||
| 99 | |||
| 100 | return Command::FAILURE; |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($delete) { |
||
| 104 | $this->tree_service->delete($tree); |
||
| 105 | $io->success(message: 'Tree ‘' . $name . '’ was deleted..'); |
||
| 106 | |||
| 107 | return self::SUCCESS; |
||
| 108 | } |
||
| 109 | |||
| 110 | if ($title === '') { |
||
| 111 | $io->info(message: 'Nothing to do. Specify --title, --create or --delete.'); |
||
| 112 | |||
| 113 | return Command::INVALID; |
||
| 114 | } |
||
| 115 | |||
| 116 | $tree->setPreference('title', $title); |
||
| 117 | $io->info(message: 'Tree title set to ‘' . $title . '’.'); |
||
| 118 | |||
| 119 | return self::SUCCESS; |
||
| 120 | } |
||
| 122 |
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