| Conditions | 11 |
| Paths | 21 |
| Total Lines | 47 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 52 | public function processRefContent($refContent): string |
||
| 53 | { |
||
| 54 | // todo // hack Temporary Skip URL |
||
| 55 | if (preg_match('#books\.google#', $refContent)) { |
||
| 56 | return $refContent; |
||
| 57 | } |
||
| 58 | |||
| 59 | try { |
||
| 60 | $result = $this->transformer->process($refContent, $this->summary); |
||
| 61 | } catch (Throwable $e) { |
||
| 62 | echo "** Problème détecté 234242\n"; |
||
| 63 | $this->log->critical($e->getMessage()." ".$e->getFile().":".$e->getLine()); |
||
| 64 | |||
| 65 | // TODO : parse $e->message pour traitement, taskName, botflag... |
||
| 66 | return $refContent; |
||
| 67 | } |
||
| 68 | |||
| 69 | if ($result === $refContent) { |
||
| 70 | return $refContent; |
||
| 71 | } |
||
| 72 | |||
| 73 | // Gestion semi-auto |
||
| 74 | if (!$this->transformer->skipUnauthorised) { |
||
| 75 | echo Color::BG_LIGHT_RED."--".Color::NORMAL." ".$refContent."\n"; |
||
| 76 | echo Color::BG_LIGHT_GREEN."++".Color::NORMAL." $result \n\n"; |
||
| 77 | |||
| 78 | if (!$this->modeAuto) { |
||
| 79 | $ask = readline(Color::LIGHT_MAGENTA."*** Conserver cette modif ? [y/n/auto]".Color::NORMAL); |
||
| 80 | if ($ask === 'auto') { |
||
| 81 | $this->modeAuto = true; |
||
| 82 | } |
||
| 83 | if ($ask !== 'y' && $ask !== 'auto') { |
||
| 84 | return $refContent; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | if (preg_match('#{{lien brisé#i', $result)) { |
||
| 89 | $this->summary->memo['count lien brisé'] = 1 + ($this->summary->memo['count lien brisé'] ?? 0); |
||
| 90 | $this->summary->setBotFlag(false); |
||
| 91 | } |
||
| 92 | if ($this->summary->citationNumber >= 8) { |
||
| 93 | $this->summary->setBotFlag(false); |
||
| 94 | } |
||
| 95 | |||
| 96 | $this->summary->memo['count URL'] = 1 + ($this->summary->memo['count URL'] ?? 0); |
||
| 97 | |||
| 98 | return $result; |
||
| 99 | } |
||
| 140 |