| Conditions | 13 |
| Paths | 147 |
| Total Lines | 59 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 53 | public function handle() |
||
| 54 | { |
||
| 55 | $editeur = $this->ouvrage->getParam('éditeur'); |
||
| 56 | if (empty($editeur)) { |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | // FIX bug "GEO Art ([[Prisma Media]]) ; [[Le Monde]]" |
||
| 61 | if (preg_match('#\[.*\[.*\[#', $editeur) > 0) { |
||
| 62 | return; |
||
| 63 | } |
||
| 64 | // FIX bug "[[Fu|Bar]] bla" => [[Fu|Bar bla]] |
||
| 65 | if (preg_match('#(.+\[\[|\]\].+)#', $editeur) > 0) { |
||
| 66 | return; |
||
| 67 | } |
||
| 68 | |||
| 69 | // [[éditeur]] |
||
| 70 | if (preg_match('#\[\[([^|]+)]]#', $editeur, $matches) > 0) { |
||
| 71 | $editeurUrl = $matches[1]; |
||
| 72 | } |
||
| 73 | // [[bla|éditeur]] |
||
| 74 | if (preg_match('#\[\[([^]|]+)\|.+]]#', $editeur, $matches) > 0) { |
||
| 75 | $editeurUrl = $matches[1]; |
||
| 76 | } |
||
| 77 | |||
| 78 | // Todo : traitement/suppression des abréviations communes : |
||
| 79 | // ['éd. de ', 'éd. du ', 'éd.', 'ed.', 'Éd. de ', 'Éd.', 'édit.', 'Édit.', '(éd.)', '(ed.)', 'Ltd.'] |
||
| 80 | |||
| 81 | $editeurStr = WikiTextUtil::unWikify($editeur); |
||
| 82 | // On garde minuscule sur éditeur, pour nuance Éditeur/éditeur permettant de supprimer "éditeur" |
||
| 83 | // ex: "éditions Milan" => "Milan" |
||
| 84 | |||
| 85 | // Déconseillé : 'lien éditeur' (obsolete 2019) |
||
| 86 | if ($this->ouvrage->hasParamValue('lien éditeur')) { |
||
| 87 | if (empty($editeurUrl)) { |
||
| 88 | $editeurUrl = $this->ouvrage->getParam('lien éditeur'); |
||
| 89 | } |
||
| 90 | $this->ouvrage->unsetParam('lien éditeur'); |
||
| 91 | } |
||
| 92 | |||
| 93 | // TODO check history |
||
| 94 | if (empty($editeurUrl)) { |
||
| 95 | $editeurUrl = $this->predictPublisherWikiTitle($editeurStr); |
||
| 96 | if (!empty($editeurUrl) && $this->articleTitle !== $editeurUrl) { |
||
| 97 | $this->optiStatus->addSummaryLog('+lien éditeur'); |
||
| 98 | $this->optiStatus->setNotCosmetic(true); |
||
| 99 | $this->optiStatus->setMajor(true); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | $newEditeur = $editeurStr; |
||
| 104 | if (!empty($editeurUrl)) { |
||
| 105 | $newEditeur = WikiTextUtil::wikilink($editeurStr, $editeurUrl); |
||
| 106 | } |
||
| 107 | |||
| 108 | if ($newEditeur !== $editeur) { |
||
| 109 | $this->ouvrage->setParam('éditeur', $newEditeur); |
||
| 110 | $this->optiStatus->addSummaryLog('±éditeur'); |
||
| 111 | $this->optiStatus->setNotCosmetic(true); |
||
| 112 | } |
||
| 141 | } |