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