Conditions | 12 |
Paths | 17 |
Total Lines | 50 |
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 |
||
26 | public function saveGettextFunctions(Translations $translations, array $options) |
||
27 | { |
||
28 | $functions = $options['functions']; |
||
29 | $file = $options['file']; |
||
30 | |||
31 | foreach ($this->getFunctions($options['constants']) as $function) { |
||
32 | list($name, $line, $args) = $function; |
||
33 | |||
34 | if (isset($options['lineOffset'])) { |
||
35 | $line += $options['lineOffset']; |
||
36 | } |
||
37 | |||
38 | if (!isset($functions[$name])) { |
||
39 | continue; |
||
40 | } |
||
41 | |||
42 | $deconstructed = $this->deconstructArgs($functions[$name], $args); |
||
43 | |||
44 | if (!$deconstructed) { |
||
45 | continue; |
||
46 | } |
||
47 | |||
48 | list($domain, $context, $original, $plural) = $deconstructed; |
||
49 | |||
50 | if ((string)$original === '') { |
||
51 | continue; |
||
52 | } |
||
53 | |||
54 | $isDefaultDomain = $domain === null; |
||
55 | $isMatchingDomain = $domain === $translations->getDomain(); |
||
56 | |||
57 | if (!empty($options['domainOnly']) && $isDefaultDomain) { |
||
58 | // If we want to find translations for a specific domain, skip default domain messages |
||
59 | continue; |
||
60 | } |
||
61 | |||
62 | if (!$isDefaultDomain && !$isMatchingDomain) { |
||
63 | continue; |
||
64 | } |
||
65 | |||
66 | $translation = $translations->insert($context, $original, $plural); |
||
67 | $translation->addReference($file, $line); |
||
68 | |||
69 | if (isset($function[3])) { |
||
70 | foreach ($function[3] as $extractedComment) { |
||
71 | $translation->addExtractedComment($extractedComment); |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | |||
157 |