| Conditions | 19 | 
| Paths | 62 | 
| Total Lines | 111 | 
| Code Lines | 69 | 
| 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  | 
            ||
| 45 | protected function execute(InputInterface $input, OutputInterface $output): int  | 
            ||
| 46 |     { | 
            ||
| 47 | $this->debugger->stop();  | 
            ||
| 48 | $config = $this->container->get(ConfigInterface::class);  | 
            ||
| 49 | |||
| 50 | $io = new SymfonyStyle($input, $output);  | 
            ||
| 51 | |||
| 52 |         if ($input->hasArgument('id') && !empty($ids = $input->getArgument('id'))) { | 
            ||
| 53 | $build = $this->getConfigBuild($config);  | 
            ||
| 54 |             foreach ($ids as $id) { | 
            ||
| 55 | $definition = null;  | 
            ||
| 56 |                 foreach ($build as $definitions) { | 
            ||
| 57 | //var_dump(array_keys($definitions));  | 
            ||
| 58 |                     if (array_key_exists($id, $definitions)) { | 
            ||
| 59 | $definition = $definitions[$id];  | 
            ||
| 60 | }  | 
            ||
| 61 | }  | 
            ||
| 62 |                 if ($definition === null) { | 
            ||
| 63 | $io->error(  | 
            ||
| 64 | sprintf(  | 
            ||
| 65 | 'Service "%s" not found',  | 
            ||
| 66 | $id,  | 
            ||
| 67 | )  | 
            ||
| 68 | );  | 
            ||
| 69 | continue;  | 
            ||
| 70 | }  | 
            ||
| 71 | $io->title($id);  | 
            ||
| 72 | |||
| 73 | $normalizedDefinition = DefinitionNormalizer::normalize($definition, $id);  | 
            ||
| 74 |                 if ($normalizedDefinition instanceof ArrayDefinition) { | 
            ||
| 75 | $definitionList = ['ID' => $id];  | 
            ||
| 76 |                     if (class_exists($normalizedDefinition->getClass())) { | 
            ||
| 77 | $definitionList[] = ['Class' => $normalizedDefinition->getClass()];  | 
            ||
| 78 | }  | 
            ||
| 79 |                     if (!empty($normalizedDefinition->getConstructorArguments())) { | 
            ||
| 80 | $definitionList[] = [  | 
            ||
| 81 | 'Constructor' => $this->export(  | 
            ||
| 82 | $normalizedDefinition->getConstructorArguments()  | 
            ||
| 83 | ),  | 
            ||
| 84 | ];  | 
            ||
| 85 | }  | 
            ||
| 86 |                     if (!empty($normalizedDefinition->getMethodsAndProperties())) { | 
            ||
| 87 | $definitionList[] = [  | 
            ||
| 88 | 'Methods' => $this->export(  | 
            ||
| 89 | $normalizedDefinition->getMethodsAndProperties()  | 
            ||
| 90 | ),  | 
            ||
| 91 | ];  | 
            ||
| 92 | }  | 
            ||
| 93 |                     if (isset($definition['tags'])) { | 
            ||
| 94 | $definitionList[] = ['Tags' => $this->export($definition['tags'])];  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 | $io->definitionList(...$definitionList);  | 
            ||
| 98 | |||
| 99 | continue;  | 
            ||
| 100 | }  | 
            ||
| 101 |                 if ($normalizedDefinition instanceof CallableDefinition || $normalizedDefinition instanceof ValueDefinition) { | 
            ||
| 102 | $io->text(  | 
            ||
| 103 | $this->export($definition)  | 
            ||
| 104 | );  | 
            ||
| 105 | continue;  | 
            ||
| 106 | }  | 
            ||
| 107 | |||
| 108 | $output->writeln([  | 
            ||
| 109 | $id,  | 
            ||
| 110 | VarDumper::create($normalizedDefinition)->asString(),  | 
            ||
| 111 | ]);  | 
            ||
| 112 | }  | 
            ||
| 113 | |||
| 114 | return ExitCode::OK;  | 
            ||
| 115 | }  | 
            ||
| 116 | |||
| 117 |         if ($input->hasOption('groups') && $input->getOption('groups')) { | 
            ||
| 118 | $build = $this->getConfigBuild($config);  | 
            ||
| 119 | $groups = array_keys($build);  | 
            ||
| 120 | ksort($groups);  | 
            ||
| 121 | |||
| 122 | $io->table(['Group'], array_map(fn ($group) => [$group], $groups));  | 
            ||
| 123 | |||
| 124 | return ExitCode::OK;  | 
            ||
| 125 | }  | 
            ||
| 126 |         if ($input->hasOption('group') && !empty($group = $input->getOption('group'))) { | 
            ||
| 127 | $data = $config->get($group);  | 
            ||
| 128 | ksort($data);  | 
            ||
| 129 | |||
| 130 | $rows = $this->getGroupServices($data);  | 
            ||
| 131 | |||
| 132 | $table = new Table($output);  | 
            ||
| 133 | $table  | 
            ||
| 134 | ->setHeaderTitle($group)  | 
            ||
| 135 | ->setHeaders(['Service', 'Definition'])  | 
            ||
| 136 | ->setRows($rows);  | 
            ||
| 137 | $table->render();  | 
            ||
| 138 | |||
| 139 | return ExitCode::OK;  | 
            ||
| 140 | }  | 
            ||
| 141 | |||
| 142 | $build = $this->getConfigBuild($config);  | 
            ||
| 143 | |||
| 144 |         foreach ($build as $group => $data) { | 
            ||
| 145 | $rows = $this->getGroupServices($data);  | 
            ||
| 146 | |||
| 147 | $table = new Table($output);  | 
            ||
| 148 | $table  | 
            ||
| 149 | ->setHeaderTitle($group)  | 
            ||
| 150 | ->setHeaders(['Group', 'Services'])  | 
            ||
| 151 | ->setRows($rows);  | 
            ||
| 152 | $table->render();  | 
            ||
| 153 | }  | 
            ||
| 154 | |||
| 155 | return ExitCode::OK;  | 
            ||
| 156 | }  | 
            ||
| 194 |