Conditions | 14 |
Paths | 5 |
Total Lines | 41 |
Code Lines | 24 |
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 |
||
22 | public function handle() |
||
23 | { |
||
24 | if (!$this->book->hasParamValue('sous-titre') |
||
25 | || !$this->origin->hasParamValue('titre') |
||
26 | || !$this->book->hasParamValue('titre') |
||
27 | ) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | // Skip pour éviter conflit entre 'sous-titre' et 'collection' ou 'titre volume' |
||
32 | if ($this->origin->hasParamValue('titre volume') |
||
33 | || $this->origin->hasParamValue('titre chapitre') |
||
34 | || $this->origin->hasParamValue('titre tome') |
||
35 | || $this->origin->hasParamValue('collection') |
||
36 | || $this->origin->hasParamValue('nature ouvrage') |
||
37 | ) { |
||
38 | return; |
||
39 | } |
||
40 | |||
41 | // simple : titres identiques mais sous-titre manquant |
||
42 | // même titre mais sous-titre manquant |
||
43 | if ( |
||
44 | $this->stripAll($this->origin->getParam('titre')) |
||
|
|||
45 | === $this->stripAll($this->book->getParam('titre')) |
||
46 | && !$this->origin->hasParamValue('sous-titre') |
||
47 | ) { |
||
48 | $this->origin->setParam('sous-titre', $this->book->getParam('sous-titre')); |
||
49 | $this->optiStatus->addSummaryLog('++sous-titre'); |
||
50 | $this->optiStatus->setMajor(true); |
||
51 | $this->optiStatus->setNotCosmetic(true); |
||
52 | |||
53 | return; |
||
54 | } |
||
55 | |||
56 | // compliqué : sous-titre inclus dans titre original => on copie titre/sous-titre de book |
||
57 | // Exclusion wikification "titre=[[Fu : Bar]]" pour éviter => "titre=Fu|sous-titre=Bar" |
||
58 | if ($this->charsFromBigTitle($this->origin) === $this->charsFromBigTitle($this->book) |
||
59 | && !WikiTextUtil::isWikify($this->origin->getParam('titre') ?? '') && !$this->origin->hasParamValue('sous-titre')) { |
||
60 | $this->origin->setParam('titre', $this->book->getParam('titre')); |
||
61 | $this->origin->setParam('sous-titre', $this->book->getParam('sous-titre')); |
||
62 | $this->optiStatus->addSummaryLog('>sous-titre'); |
||
63 | } |
||
65 | } |