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