Conditions | 13 |
Paths | 45 |
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 |
||
30 | public static function canonicalizeData( |
||
31 | DOMElement $element, |
||
32 | string $c14nMethod, |
||
33 | array $xpaths = null, |
||
34 | array $prefixes = null |
||
35 | ): string { |
||
36 | $exclusive = false; |
||
37 | $withComments = false; |
||
38 | switch ($c14nMethod) { |
||
39 | case C::C14N_EXCLUSIVE_WITH_COMMENTS: |
||
40 | case C::C14N_INCLUSIVE_WITH_COMMENTS: |
||
41 | $withComments = true; |
||
42 | } |
||
43 | switch ($c14nMethod) { |
||
44 | case C::C14N_EXCLUSIVE_WITH_COMMENTS: |
||
45 | case C::C14N_EXCLUSIVE_WITHOUT_COMMENTS: |
||
46 | $exclusive = true; |
||
47 | } |
||
48 | |||
49 | if ( |
||
50 | is_null($xpaths) |
||
51 | && ($element->ownerDocument !== null) |
||
52 | && $element->isSameNode($element->ownerDocument->documentElement) |
||
53 | ) { |
||
54 | // check for any PI or comments as they would have been excluded |
||
55 | $current = $element; |
||
56 | while ($refNode = $current->previousSibling) { |
||
57 | if ( |
||
58 | (($refNode->nodeType === XML_COMMENT_NODE) && $withComments) |
||
59 | || $refNode->nodeType === XML_PI_NODE |
||
60 | ) { |
||
61 | break; |
||
62 | } |
||
63 | $current = $refNode; |
||
64 | } |
||
65 | if ($refNode == null) { |
||
66 | $element = $element->ownerDocument; |
||
67 | } |
||
68 | } |
||
69 | |||
70 | return $element->C14N($exclusive, $withComments, $xpaths, $prefixes); |
||
71 | } |
||
144 | } |