| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| Code Lines | 38 |
| 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 |
||
| 33 | public function register(Container $container): void |
||
| 34 | { |
||
| 35 | $container['serializer.content.class'] = Html::class; |
||
| 36 | $container['serializer.content'] = static function () use ($container) : Content { |
||
| 37 | return new $container['serializer.content.class']; |
||
| 38 | }; |
||
| 39 | |||
| 40 | $container['serializer.front-matter.class'] = Yaml::class; |
||
| 41 | $container['serializer.front-matter'] = static function () use ($container) : Data { |
||
| 42 | return new $container['serializer.front-matter.class']; |
||
| 43 | }; |
||
| 44 | |||
| 45 | $container['serializer.data.class'] = Yaml::class; |
||
| 46 | $container['serializer.data'] = static function () use ($container) : Data { |
||
| 47 | return new $container['serializer.data.class']; |
||
| 48 | }; |
||
| 49 | |||
| 50 | $container['filesystem'] = static function (): Filesystem { |
||
| 51 | return new Filesystem(); |
||
| 52 | }; |
||
| 53 | |||
| 54 | $container['storage'] = static function () use ($container) : Write { |
||
| 55 | return new Storage( |
||
| 56 | 'output', $container['filesystem'], $container['serializer.content'], |
||
| 57 | $container['serializer.front-matter'], $container['serializer.data'] |
||
| 58 | ); |
||
| 59 | }; |
||
| 60 | |||
| 61 | $container['handler.config'] = static function () use ($container) : Config { |
||
| 62 | return new Config($container['storage']); |
||
| 63 | }; |
||
| 64 | |||
| 65 | $container['handler.author'] = static function () use ($container) : Handler { |
||
| 66 | return new Author($container['storage']); |
||
| 67 | }; |
||
| 68 | |||
| 69 | $container['handler.term'] = static function () use ($container) : Handler { |
||
| 70 | return new Term($container['storage'], $container['handler.config']); |
||
| 71 | }; |
||
| 72 | |||
| 73 | $container['handler.post'] = static function () use ($container) : Handler { |
||
| 74 | return new Post($container['storage']); |
||
| 75 | }; |
||
| 76 | |||
| 77 | $container['processor'] = static function () use ($container) : Processor { |
||
| 78 | $processor = new Processor(); |
||
| 79 | $config = $container['handler.config']; |
||
| 80 | $term = $container['handler.term']; |
||
| 81 | |||
| 82 | $processor->addHandler('title', $config); |
||
| 83 | $processor->addHandler('description', $config); |
||
| 84 | $processor->addHandler('link', $config); |
||
| 85 | $processor->addHandler('author', $container['handler.author']); |
||
| 86 | $processor->addHandler('category', $term); |
||
| 87 | $processor->addHandler('tag', $term); |
||
| 88 | $processor->addHandler('term', $term); |
||
| 89 | $processor->addHandler('item', $container['handler.post']); |
||
| 90 | |||
| 91 | return $processor; |
||
| 92 | }; |
||
| 93 | |||
| 94 | $container['command.import'] = static function () use ($container) : Import { |
||
| 95 | return new Import($container); |
||
| 96 | }; |
||
| 99 |