| Conditions | 1 |
| Paths | 1 |
| Total Lines | 92 |
| Code Lines | 58 |
| 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 |
||
| 69 | public function define(Container $di) |
||
| 70 | { |
||
| 71 | $di->set(\Sabre\Xml\Writer::class, $di->lazyNew(\Sabre\Xml\Writer::class)); |
||
| 72 | |||
| 73 | $di->set(BlogOverviewAction::class, $di->lazyNew(BlogOverviewAction::class, [ |
||
| 74 | 'templateRenderer' => $di->lazyGet(TemplateRendererInterface::class), |
||
| 75 | 'entryParser' => $di->lazyGet(EntryParser::class), |
||
| 76 | 'markdownCmsConfig' => $this->config['markdown_cms'], |
||
| 77 | ])); |
||
| 78 | |||
| 79 | $di->set(SingleBlogEntryAction::class, $di->lazyNew(SingleBlogEntryAction::class, [ |
||
| 80 | 'templateRenderer' => $di->lazyGet(TemplateRendererInterface::class), |
||
| 81 | 'entryParser' => $di->lazyGet(EntryParser::class), |
||
| 82 | 'markdownCmsConfig' => $this->config['markdown_cms'], |
||
| 83 | ])); |
||
| 84 | |||
| 85 | $di->set(TagArchiveAction::class, $di->lazyNew(TagArchiveAction::class, [ |
||
| 86 | 'templateRenderer' => $di->lazyGet(TemplateRendererInterface::class), |
||
| 87 | 'entryParser' => $di->lazyGet(EntryParser::class), |
||
| 88 | 'markdownCmsConfig' => $this->config['markdown_cms'], |
||
| 89 | ])); |
||
| 90 | |||
| 91 | $di->set(ContentCreator::class, $di->lazyNew(ContentCreator::class, [ |
||
| 92 | 'options' => $this->config['markdown_cms']['options'] |
||
| 93 | ])); |
||
| 94 | |||
| 95 | $di->set(ContentParser::class, $di->lazyNew(ContentParser::class, [ |
||
| 96 | 'markdownFileIterator' => $di->lazyGet(MarkdownFileIterator::class), |
||
| 97 | 'contentCreator' => $di->lazyGet(ContentCreator::class), |
||
| 98 | 'mdDocumentParser' => $di->lazyGet(MarkdownDocumentParser::class), |
||
| 99 | 'markdownOptions' => $this->config['markdown_cms']['options'], |
||
| 100 | ])); |
||
| 101 | |||
| 102 | $di->set(MarkdownDocumentParser::class, $di->lazyNew(MarkdownDocumentParser::class, [ |
||
| 103 | 'frontYamlParser' => $di->lazyGet(Parser::class) |
||
| 104 | ])); |
||
| 105 | |||
| 106 | $di->set(MarkdownFileIterator::class, $di->lazyNew(MarkdownFileIterator::class, [ |
||
| 107 | 'iterator' => $di->lazyNew(\RecursiveIteratorIterator::class, [ |
||
| 108 | 'iterator' => $di->lazyNew(\RecursiveDirectoryIterator::class, [ |
||
| 109 | 'path' => $this->config['markdown_cms']['options']['content_dir'], |
||
| 110 | 'flags' => null |
||
| 111 | ]), |
||
| 112 | 'mode' => null, |
||
| 113 | 'flags' => null, |
||
| 114 | ]), |
||
| 115 | 'regex' => '/^.+\.md$/i', |
||
| 116 | 'mode' => \RecursiveRegexIterator::MATCH, |
||
| 117 | 'flags' => null, |
||
| 118 | 'preg_flags'=> null |
||
| 119 | ])); |
||
| 120 | |||
| 121 | $di->set(ImageRenderer::class, $di->lazyNew(ImageRenderer::class, [ |
||
| 122 | 'urlTranslation' => $this->config['markdown_cms']['options']['url_translation'] |
||
| 123 | ])); |
||
| 124 | |||
| 125 | |||
| 126 | $di->set(EnvironmentFactory::class, $di->lazyNew(EnvironmentFactory::class)); |
||
| 127 | $di->set(Environment::class, $di->lazyGetCall(EnvironmentFactory::class, '__invoke', $di)); |
||
| 128 | |||
| 129 | $di->set(Parser::class, $di->lazyNew(Parser::class, [ |
||
| 130 | 'yamlParser' => null, |
||
| 131 | 'markdownParser' => $di->lazyNew(CommonMarkParser::class, [ |
||
| 132 | 'commonMarkConverter' => $di->lazyNew(CommonMarkConverter::class, [ |
||
| 133 | 'environment' => $di->lazyGet(Environment::class) |
||
| 134 | ]) |
||
| 135 | ]) |
||
| 136 | ])); |
||
| 137 | |||
| 138 | $di->set(ParseContentCommand::class, $di->lazyNew(ParseContentCommand::class)); |
||
| 139 | $di->setters[ParseContentCommand::class] = [ |
||
| 140 | 'setParseContentExecutor' => $di->lazyGet(ParseContentExecutor::class) |
||
| 141 | ]; |
||
| 142 | |||
| 143 | $di->set(SaveContentConfigObserver::class, $di->lazyNew(SaveContentConfigObserver::class, [ |
||
| 144 | 'configWriter' => $di->lazyNew(PhpArray::class), |
||
| 145 | 'targetPath' => $this->config['markdown_cms']['options']['content_config_path'] |
||
| 146 | ])); |
||
| 147 | |||
| 148 | $di->set(SitemapObserver::class, $di->lazyNew(SitemapObserver::class, [ |
||
| 149 | 'xmlWriter' => $di->lazyNew(\Sabre\Xml\Writer::class), |
||
| 150 | 'sitemapPath' => $this->config['markdown_cms']['options']['sitemap_path'], |
||
| 151 | 'baseUrl' => $this->config['markdown_cms']['options']['base_url'] |
||
| 152 | ])); |
||
| 153 | |||
| 154 | $di->set(EntryParser::class, $di->lazyNew(EntryParser::class, [ |
||
| 155 | 'contentCreator' => $di->lazyGet(ContentCreator::class), |
||
| 156 | 'mdDocumentParser' => $di->lazyGet(MarkdownDocumentParser::class), |
||
| 157 | 'config' => $this->config['markdown_cms']['content']['all'], |
||
| 158 | 'contentDir' => $this->config['markdown_cms']['options']['content_dir'] |
||
| 159 | ])); |
||
| 160 | } |
||
| 161 | |||
| 170 | } |