Conditions | 10 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 20 |
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 |
||
65 | public function actionTranslation($options) |
||
66 | { |
||
67 | if (!is_array($options)) { |
||
68 | return $this->translator->trans($options, [], 'CmsKernelAdminBridge'); |
||
69 | } |
||
70 | |||
71 | $resultOptions = []; |
||
72 | foreach ($options as $optionKey => $option) { |
||
73 | $option = null === json_decode($option, true) ? $option : json_decode($option, true); |
||
74 | |||
75 | if (is_array($option)) { |
||
76 | foreach ($option as $iterationKey => $iteration) { |
||
77 | if (is_array($iteration)) { |
||
78 | foreach ($iteration as $iKey => $i) { |
||
79 | if (is_array($i)) { |
||
80 | foreach ($i as $iiKey => $ii) { |
||
81 | $resultOptions[$optionKey][$iterationKey][$iKey][$iiKey] = $this->translator->trans($ii); |
||
82 | } |
||
83 | } else { |
||
84 | $resultOptions[$optionKey][$iterationKey][$iKey] = $this->translator->trans($i); |
||
85 | } |
||
86 | } |
||
87 | } else { |
||
88 | $resultOptions[$optionKey][$iterationKey] = $this->translator->trans($iteration); |
||
89 | } |
||
90 | } |
||
91 | } else { |
||
92 | $resultOptions[$optionKey] = $this->translator->trans($option); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | return $resultOptions; |
||
97 | } |
||
98 | } |
||
99 |