| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 35 | public function register(ContainerFactory $factory) |
||
| 36 | { |
||
| 37 | $composerHome = $this->composerHome; |
||
| 38 | |||
| 39 | $factory->register(ArgvInput::class); |
||
| 40 | $factory->register(ConsoleOutput::class); |
||
| 41 | |||
| 42 | $factory->alias(InputInterface::class, ArgvInput::class); |
||
| 43 | $factory->alias(OutputInterface::class, ConsoleOutput::class); |
||
| 44 | |||
| 45 | $factory->configure( |
||
| 46 | ConsoleOutput::class, |
||
| 47 | function (ConsoleOutput $output) { |
||
| 48 | $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red', null, [])); |
||
| 49 | $output->getFormatter()->setStyle('success', new OutputFormatterStyle('green', null, [])); |
||
| 50 | return $output; |
||
| 51 | } |
||
| 52 | ); |
||
| 53 | |||
| 54 | $factory->set( |
||
| 55 | Helper\HelperSet::class, |
||
| 56 | new Helper\HelperSet([ |
||
| 57 | new Helper\FormatterHelper(), |
||
| 58 | new Helper\DebugFormatterHelper(), |
||
| 59 | new Helper\ProcessHelper(), |
||
| 60 | new Helper\QuestionHelper(), |
||
| 61 | ]) |
||
| 62 | ); |
||
| 63 | |||
| 64 | $factory->register(VersionParser::class); |
||
| 65 | $factory->register(CrapHelper::class); |
||
| 66 | $factory->register(Crap::class); |
||
| 67 | |||
| 68 | $factory->register( |
||
| 69 | JsonFileStore::class, |
||
| 70 | function () use ($composerHome) { |
||
| 71 | $file = sprintf('%s/%s', $composerHome, Crap::FILENAME); |
||
| 72 | $flags = JsonFileStore::NO_SERIALIZE_STRINGS |
||
| 73 | | JsonFileStore::PRETTY_PRINT |
||
| 74 | | JsonFileStore::NO_ESCAPE_SLASH; |
||
| 75 | return new JsonFileStore($file, $flags); |
||
| 76 | } |
||
| 77 | ); |
||
| 78 | |||
| 79 | $factory->configure( |
||
| 80 | Crap::class, |
||
| 81 | function (Crap $crap, CrapHelper $helper) { |
||
| 82 | $crap->addCommands([ |
||
| 83 | new Command\ListAliasesCommand($helper), |
||
| 84 | new Command\AliasCommand($helper), |
||
| 85 | new Command\InfoCommand($helper), |
||
| 86 | new Command\UnaliasCommand($helper), |
||
| 87 | new Command\RequireCommand($helper), |
||
| 88 | new Command\UpdateCommand($helper), |
||
| 89 | new Command\RemoveCommand($helper), |
||
| 90 | new Command\ProjectCommand($helper), |
||
| 91 | ]); |
||
| 92 | return $crap; |
||
| 93 | } |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | } |
||
| 97 |