| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 44 | public function define(Container $di) |
||
| 45 | { |
||
| 46 | $di->set(\Sabre\Xml\Writer::class, $di->lazyNew(\Sabre\Xml\Writer::class)); |
||
| 47 | |||
| 48 | $di->set(BlogOverviewAction::class, $di->lazyNew(BlogOverviewAction::class)); |
||
| 49 | $di->params[BlogOverviewAction::class] = [ |
||
| 50 | 'templateRenderer' => $di->lazyGet(TemplateRendererInterface::class), |
||
| 51 | 'contentCreator' => $di->lazyGet(ContentCreator::class), |
||
| 52 | 'markdownDocumentParser' => $di->lazyGet(MarkdownDocumentParser::class), |
||
| 53 | 'markdownCmsConfig' => $this->config['markdown_cms'], |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $di->set(SingleBlogEntryAction::class, $di->lazyNew(SingleBlogEntryAction::class)); |
||
| 57 | $di->params[SingleBlogEntryAction::class] = [ |
||
| 58 | 'templateRenderer' => $di->lazyGet(TemplateRendererInterface::class), |
||
| 59 | 'contentCreator' => $di->lazyGet(ContentCreator::class), |
||
| 60 | 'markdownDocumentParser' => $di->lazyGet(MarkdownDocumentParser::class), |
||
| 61 | 'markdownCmsConfig' => $this->config['markdown_cms'], |
||
| 62 | ]; |
||
| 63 | |||
| 64 | $di->set(ContentCreator::class, $di->lazyNew(ContentCreator::class)); |
||
| 65 | $di->params[ContentCreator::class] = [ |
||
| 66 | 'options' => $this->config['markdown_cms']['options'] |
||
| 67 | ]; |
||
| 68 | |||
| 69 | $di->set(ContentParser::class, $di->lazyNew(ContentParser::class)); |
||
| 70 | $di->params[ContentParser::class] = [ |
||
| 71 | 'markdownFileIterator' => $di->lazyGet(MarkdownFileIterator::class), |
||
| 72 | 'contentCreator' => $di->lazyGet(ContentCreator::class), |
||
| 73 | 'markdownDocumentParser' => $di->lazyGet(MarkdownDocumentParser::class), |
||
| 74 | 'markdownOptions' => $this->config['markdown_cms']['options'], |
||
| 75 | |||
| 76 | ]; |
||
| 77 | |||
| 78 | $di->set(MarkdownDocumentParser::class, $di->lazyNew(MarkdownDocumentParser::class)); |
||
| 79 | $di->params[MarkdownDocumentParser::class] = [ |
||
| 80 | 'frontYamlParser' => $di->lazyGet(Parser::class) |
||
| 81 | ]; |
||
| 82 | |||
| 83 | $di->set(MarkdownFileIterator::class, $di->lazyNew(MarkdownFileIterator::class, [ |
||
| 84 | 'iterator' => $di->lazyNew(\RecursiveIteratorIterator::class, [ |
||
| 85 | 'iterator' => $di->lazyNew(\RecursiveDirectoryIterator::class, [ |
||
| 86 | 'path' => $this->config['markdown_cms']['options']['content_dir'], |
||
| 87 | 'flags' => null |
||
| 88 | ]), |
||
| 89 | 'mode' => null, |
||
| 90 | 'flags' => null, |
||
| 91 | ]), |
||
| 92 | 'regex' => '/^.+\.md$/i', |
||
| 93 | 'mode' => \RecursiveRegexIterator::MATCH, |
||
| 94 | 'flags' => null, |
||
| 95 | 'preg_flags'=> null |
||
| 96 | ])); |
||
| 97 | |||
| 98 | $di->set(Parser::class, $di->lazyNew(Parser::class, [ |
||
| 99 | 'yamlParser' => null, |
||
| 100 | 'markdownParser' => $di->lazyNew(CommonMarkParser::class, [ |
||
| 101 | 'commonMarkConverter' => $di->lazyNew(CommonMarkConverter::class) |
||
| 102 | ]) |
||
| 103 | ])); |
||
| 104 | |||
| 105 | $di->set(ParseContentCommand::class, $di->lazyNew(ParseContentCommand::class)); |
||
| 106 | $di->setters[ParseContentCommand::class] = [ |
||
| 107 | 'setParseContentExecutor' => $di->lazyGet(ParseContentExecutor::class) |
||
| 108 | ]; |
||
| 109 | |||
| 110 | $di->set(SaveContentConfigObserver::class, $di->lazyNew(SaveContentConfigObserver::class, [ |
||
| 111 | 'configWriter' => $di->lazyNew(PhpArray::class), |
||
| 112 | 'targetPath' => $this->config['markdown_cms']['options']['content_config_path'] |
||
| 113 | ])); |
||
| 114 | |||
| 115 | $di->set(SitemapObserver::class, $di->lazyNew(SitemapObserver::class, [ |
||
| 116 | 'xmlWriter' => $di->lazyNew(\Sabre\Xml\Writer::class), |
||
| 117 | 'sitemapPath' => $this->config['markdown_cms']['options']['sitemap_path'], |
||
| 118 | 'baseUrl' => $this->config['markdown_cms']['options']['base_url'] |
||
| 119 | ])); |
||
| 120 | } |
||
| 121 | |||
| 130 | } |