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