Conditions | 13 |
Paths | 40 |
Total Lines | 34 |
Code Lines | 18 |
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 |
||
57 | protected function replaceSitenameByConfig(array $mapData, $template): array |
||
58 | { |
||
59 | // from wikidata URL of newspapers |
||
60 | if (!empty($this->publisherData['newspaper'][$this->registrableDomain])) { |
||
61 | $frwiki = $this->publisherData['newspaper'][$this->registrableDomain]['frwiki']; |
||
62 | $label = $this->publisherData['newspaper'][$this->registrableDomain]['fr']; |
||
63 | if (isset($mapData['site']) || $template instanceof LienWebTemplate) { |
||
64 | $mapData['site'] = WikiTextUtil::wikilink($label, $frwiki); |
||
65 | } |
||
66 | if (isset($mapData['périodique']) || $template instanceof ArticleTemplate) { |
||
67 | $mapData['périodique'] = WikiTextUtil::wikilink($label, $frwiki); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | // from wikidata of scientific journals |
||
72 | if (isset($mapData['périodique']) && isset($this->publisherData['scientific wiki'][$mapData['périodique']])) { |
||
73 | $mapData['périodique'] = WikiTextUtil::wikilink( |
||
74 | $mapData['périodique'], |
||
75 | $this->publisherData['scientific wiki'][$mapData['périodique']] |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | // from YAML config |
||
80 | if (!empty($this->config[$this->registrableDomain]['site']) && $template instanceof LienWebTemplate) { |
||
81 | $mapData['site'] = $this->config[$this->registrableDomain]['site']; |
||
82 | } |
||
83 | if (!empty($this->config[$this->registrableDomain]['périodique']) |
||
84 | && (!empty($mapData['périodique']) |
||
85 | || $template instanceof OuvrageTemplate) |
||
86 | ) { |
||
87 | $mapData['périodique'] = $this->config[$this->registrableDomain]['périodique']; |
||
88 | } |
||
89 | |||
90 | return $mapData; |
||
91 | } |
||
100 | } |