| Conditions | 3 |
| Paths | 3 |
| Total Lines | 51 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 48 | public function doTasks(): self |
||
| 49 | { |
||
| 50 | $this->optiStatus = new OptiStatus(); // move to AbstractTemplateOptimizer ? |
||
| 51 | $optiStatus = $this->optiStatus; |
||
| 52 | |||
| 53 | // Composite handler |
||
| 54 | $handlers = [ |
||
| 55 | new PredictErrorParameterHandler($this->optiTemplate, $optiStatus), |
||
| 56 | new DistinguishAuthorsHandler($this->optiTemplate, $optiStatus), |
||
| 57 | new LangParamHandler($this->optiTemplate, $optiStatus), |
||
| 58 | (new LangParamHandler($this->optiTemplate, $optiStatus))->setLangParam('langue originale'), |
||
| 59 | new TitleHandler($this->optiTemplate, $optiStatus), |
||
| 60 | new AuthorLinkHandler($this->optiTemplate, $optiStatus), |
||
| 61 | new EditionCitebookHandler($this->optiTemplate, $optiStatus), |
||
| 62 | new EditeurHandler($this->optiTemplate, $optiStatus, $this->wikiPageTitle, $this->log), |
||
| 63 | new DateHandler($this->optiTemplate, $optiStatus), |
||
| 64 | new ExternalTemplateHandler($this->optiTemplate, $optiStatus), |
||
| 65 | new OuvrageFormatHandler($this->optiTemplate, $optiStatus), |
||
| 66 | new OuvrageIsbnHandler($this->optiTemplate, $optiStatus), |
||
| 67 | new BnfParamHandler($this->optiTemplate, $optiStatus), |
||
| 68 | new LocationHandler($this->optiTemplate, $optiStatus, $this->pageListManager), |
||
|
|
|||
| 69 | new GoogleBooksUrlHandler($this->optiTemplate, $optiStatus), |
||
| 70 | (new GoogleBooksUrlHandler($this->optiTemplate, $optiStatus)) |
||
| 71 | ->sethandlerParam('présentation en ligne'), |
||
| 72 | new PredictErrorParameterHandler($this->optiTemplate, $optiStatus), |
||
| 73 | new DistinguishAuthorsHandler($this->optiTemplate, $optiStatus), |
||
| 74 | new LangParamHandler($this->optiTemplate, $optiStatus), |
||
| 75 | (new LangParamHandler($this->optiTemplate, $optiStatus))->setLangParam('langue originale'), |
||
| 76 | new TitleHandler($this->optiTemplate, $optiStatus), |
||
| 77 | new AuthorLinkHandler($this->optiTemplate, $optiStatus), |
||
| 78 | new EditionCitebookHandler($this->optiTemplate, $optiStatus), |
||
| 79 | new EditeurHandler($this->optiTemplate, $optiStatus, $this->wikiPageTitle, $this->log), |
||
| 80 | new DateHandler($this->optiTemplate, $optiStatus), |
||
| 81 | new ExternalTemplateHandler($this->optiTemplate, $optiStatus), |
||
| 82 | new OuvrageFormatHandler($this->optiTemplate, $optiStatus), |
||
| 83 | new OuvrageIsbnHandler($this->optiTemplate, $optiStatus), |
||
| 84 | new BnfParamHandler($this->optiTemplate, $optiStatus), |
||
| 85 | new LocationHandler($this->optiTemplate, $optiStatus, $this->pageListManager), |
||
| 86 | new GoogleBooksUrlHandler($this->optiTemplate, $optiStatus), |
||
| 87 | (new GoogleBooksUrlHandler($this->optiTemplate, $optiStatus)) |
||
| 88 | ->sethandlerParam('présentation en ligne'), |
||
| 89 | ]; |
||
| 90 | |||
| 91 | foreach ($handlers as $handler) { |
||
| 92 | if (!$handler instanceof OptimizeHandlerInterface) { |
||
| 93 | throw new \LogicException('Handler must implement OptimizeHandlerInterface'); |
||
| 94 | } |
||
| 95 | $handler->handle(); |
||
| 96 | } |
||
| 97 | |||
| 98 | return $this; |
||
| 99 | } |
||
| 111 |