Conditions | 10 |
Paths | 5 |
Total Lines | 38 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 | $withComments = match ($c14nMethod) { |
||
40 | C::C14N_EXCLUSIVE_WITH_COMMENTS, C::C14N_INCLUSIVE_WITH_COMMENTS => true, |
||
41 | default => false, |
||
42 | }; |
||
43 | $exclusive = match ($c14nMethod) { |
||
44 | C::C14N_EXCLUSIVE_WITH_COMMENTS, C::C14N_EXCLUSIVE_WITHOUT_COMMENTS => true, |
||
45 | default => false, |
||
46 | }; |
||
47 | |||
48 | if ( |
||
49 | is_null($xpaths) |
||
50 | && ($element->ownerDocument !== null) |
||
51 | && ($element->ownerDocument->documentElement !== 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 | for ($refNode = $current->previousSibling; $refNode !== null; $current = $refNode) { |
||
|
|||
57 | if ( |
||
58 | (($refNode->nodeType === XML_COMMENT_NODE) && $withComments) |
||
59 | || $refNode->nodeType === XML_PI_NODE |
||
60 | ) { |
||
61 | break; |
||
62 | } |
||
63 | } |
||
64 | |||
65 | if ($refNode === null) { |
||
66 | $element = $element->ownerDocument; |
||
67 | } |
||
68 | } |
||
69 | |||
70 | return $element->C14N($exclusive, $withComments, $xpaths, $prefixes); |
||
71 | } |
||
125 |