| Conditions | 2 |
| Paths | 2 |
| Total Lines | 63 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | 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 |
||
| 113 | protected function create_dic(\Closure $postprocess_dic) { |
||
| 114 | $container = new Container(); |
||
| 115 | |||
| 116 | $container["rule_loader"] = function($c) { |
||
| 117 | return new RuleLoader(); |
||
| 118 | }; |
||
| 119 | |||
| 120 | $container["engine"] = function($c) { |
||
| 121 | return new Engine |
||
| 122 | ( $c["config"] |
||
| 123 | , $c["indexer"] |
||
| 124 | , $c["analyzer"] |
||
| 125 | ); |
||
| 126 | }; |
||
| 127 | |||
| 128 | $container["indexer"] = function($c) { |
||
| 129 | return new \Lechimp\Dicto\Indexer\Indexer |
||
| 130 | ( $c["php_parser"] |
||
| 131 | , $c["config"]->project_root() |
||
| 132 | , $c["database"] |
||
| 133 | ); |
||
| 134 | }; |
||
| 135 | |||
| 136 | $container["php_parser"] = function($c) { |
||
| 137 | return (new ParserFactory)->create(ParserFactory::PREFER_PHP7); |
||
| 138 | }; |
||
| 139 | |||
| 140 | $container["database"] = function($c) { |
||
| 141 | $db = new DB($c["connection"]); |
||
| 142 | $db->init_sqlite_regexp(); |
||
| 143 | $db->maybe_init_database_schema(); |
||
| 144 | return $db; |
||
| 145 | }; |
||
| 146 | |||
| 147 | $container["connection"] = function($c) { |
||
| 148 | return DriverManager::getConnection |
||
| 149 | ( array |
||
| 150 | ( "driver" => "pdo_sqlite" |
||
| 151 | , "memory" => $c["config"]->sqlite_memory() |
||
| 152 | , "path" => $c["config"]->sqlite_path() |
||
| 153 | ) |
||
| 154 | ); |
||
| 155 | }; |
||
| 156 | |||
| 157 | $container["analyzer"] = function($c) { |
||
| 158 | return new \Lechimp\Dicto\Analysis\Analyzer |
||
| 159 | ( $c["ruleset"] |
||
| 160 | , $c["database"] |
||
| 161 | , $c["report_generator"] |
||
| 162 | ); |
||
| 163 | }; |
||
| 164 | |||
| 165 | $container["report_generator"] = function($c) { |
||
| 166 | return new CLIReportGenerator(); |
||
| 167 | }; |
||
| 168 | |||
| 169 | $container = $postprocess_dic($container); |
||
| 170 | if (!($container instanceof Container)) { |
||
| 171 | throw new \RuntimeException |
||
| 172 | ("DIC postprocessor did not return a Container."); |
||
| 173 | } |
||
| 174 | return $container; |
||
| 175 | } |
||
| 176 | } |
||
| 177 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.