| Conditions | 30 |
| Paths | 17 |
| Total Lines | 50 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 declare(strict_types=1); |
||
| 28 | public static function isEqualNode(?DOMNode $node, ?DOMNode $otherNode): bool |
||
| 29 | { |
||
| 30 | if (!isset($node, $otherNode) || $node->nodeType !== $otherNode->nodeType) |
||
| 31 | { |
||
| 32 | return false; |
||
| 33 | } |
||
| 34 | if ($node instanceof DOMElement && $otherNode instanceof DOMElement) |
||
| 35 | { |
||
| 36 | return static::isEqualElementNode($node, $otherNode); |
||
| 37 | } |
||
| 38 | if ($node instanceof DOMCharacterData && $otherNode instanceof DOMCharacterData) |
||
| 39 | { |
||
| 40 | // Covers DOMCdataSection, DOMComment, and DOMText |
||
| 41 | return $node->data === $otherNode->data; |
||
| 42 | } |
||
| 43 | if ($node instanceof DOMProcessingInstruction && $otherNode instanceof DOMProcessingInstruction) |
||
| 44 | { |
||
| 45 | return $node->target === $otherNode->target && $node->data === $otherNode->data; |
||
| 46 | } |
||
| 47 | if ($node instanceof DOMAttr && $otherNode instanceof DOMAttr) |
||
| 48 | { |
||
| 49 | return $node->namespaceURI === $otherNode->namespaceURI |
||
| 50 | && $node->localName === $otherNode->localName |
||
| 51 | && $node->value === $otherNode->value; |
||
| 52 | } |
||
| 53 | if (($node instanceof DOMDocument && $otherNode instanceof DOMDocument) |
||
| 54 | || ($node instanceof DOMDocumentFragment && $otherNode instanceof DOMDocumentFragment)) |
||
| 55 | { |
||
| 56 | return static::isEqualNodeList($node->childNodes, $otherNode->childNodes); |
||
| 57 | } |
||
| 58 | if ($node instanceof DOMDocumentType && $otherNode instanceof DOMDocumentType) |
||
| 59 | { |
||
| 60 | return $node->name === $otherNode->name |
||
| 61 | && $node->publicId === $otherNode->publicId |
||
| 62 | && $node->systemId === $otherNode->systemId; |
||
| 63 | } |
||
| 64 | if ($node instanceof DOMEntityReference && $otherNode instanceof DOMEntityReference) |
||
| 65 | { |
||
| 66 | return $node->nodeName === $otherNode->nodeName; |
||
| 67 | } |
||
| 68 | if (($node instanceof DOMEntity && $otherNode instanceof DOMEntity) |
||
| 69 | || ($node instanceof DOMNotation && $otherNode instanceof DOMNotation)) |
||
| 70 | { |
||
| 71 | return $node->nodeName === $otherNode->nodeName |
||
| 72 | && $node->publicId === $otherNode->publicId |
||
| 73 | && $node->systemId === $otherNode->systemId; |
||
| 74 | } |
||
| 75 | |||
| 76 | // @codeCoverageIgnoreStart |
||
| 77 | return $node->isSameNode($otherNode); |
||
| 78 | // @codeCoverageIgnoreEnd |
||
| 142 | } |