Conditions | 10 |
Paths | 10 |
Total Lines | 25 |
Code Lines | 17 |
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 |
||
26 | public static function applyAdditionMarkupFunction($dataItem, $valueToRender, $renderedText) |
||
27 | { |
||
28 | $markupExtension = CiteProc::getContext()->getMarkupExtension(); |
||
29 | if (array_key_exists($valueToRender, $markupExtension)) { |
||
30 | if (is_array($markupExtension[$valueToRender]) && array_key_exists('function', $markupExtension[$valueToRender])) { |
||
31 | $function = $markupExtension[$valueToRender]['function']; |
||
32 | } else { |
||
33 | $function = $markupExtension[$valueToRender]; |
||
34 | } |
||
35 | if (is_callable($function)) { |
||
36 | $renderedText = $function($dataItem, $renderedText); |
||
37 | } |
||
38 | } elseif (array_key_exists($mode = CiteProc::getContext()->getMode(), $markupExtension)) { |
||
39 | if (array_key_exists($valueToRender, $markupExtension[$mode])) { |
||
40 | if (is_array($markupExtension[$mode][$valueToRender]) && array_key_exists('function', $markupExtension[$mode][$valueToRender])) { |
||
41 | $function = CiteProc::getContext()->getMarkupExtension()[$mode][$valueToRender]['function']; |
||
42 | } else { |
||
43 | $function = CiteProc::getContext()->getMarkupExtension()[$mode][$valueToRender]; |
||
44 | } |
||
45 | if (is_callable($function)) { |
||
46 | $renderedText = $function($dataItem, $renderedText); |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | return $renderedText; |
||
51 | } |
||
89 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.