Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / caxy / php-htmldiff / lib / Caxy / HtmlDiff / Table / AbstractTableElement.php
1 <?php
2
3 namespace Caxy\HtmlDiff\Table;
4
5 /**
6  * Class AbstractTableElement.
7  */
8 abstract class AbstractTableElement
9 {
10     /**
11      * @var \DOMElement
12      */
13     protected $domNode;
14
15     /**
16      * AbstractTableElement constructor.
17      *
18      * @param \DOMElement|null $domNode
19      */
20     public function __construct(\DOMElement $domNode = null)
21     {
22         $this->domNode = $domNode;
23     }
24
25     /**
26      * @return \DOMElement
27      */
28     public function getDomNode()
29     {
30         return $this->domNode;
31     }
32
33     /**
34      * @param \DOMElement $domNode
35      *
36      * @return $this
37      */
38     public function setDomNode(\DOMElement $domNode)
39     {
40         $this->domNode = $domNode;
41
42         return $this;
43     }
44
45     /**
46      * @return string
47      */
48     public function getInnerHtml()
49     {
50         $innerHtml = '';
51
52         if ($this->domNode) {
53             foreach ($this->domNode->childNodes as $child) {
54                 $innerHtml .= static::htmlFromNode($child);
55             }
56         }
57
58         return $innerHtml;
59     }
60
61     /**
62      * @param string $name
63      *
64      * @return string
65      */
66     public function getAttribute($name)
67     {
68         return $this->domNode->getAttribute($name);
69     }
70
71     /**
72      * @param \DOMDocument $domDocument
73      *
74      * @return \DOMElement
75      */
76     public function cloneNode(\DOMDocument $domDocument)
77     {
78         return $domDocument->importNode($this->getDomNode()->cloneNode(false), false);
79     }
80
81     /**
82      * @param \DOMElement $node
83      *
84      * @return string
85      */
86     public static function htmlFromNode($node)
87     {
88         $domDocument = new \DOMDocument();
89         $newNode = $domDocument->importNode($node, true);
90         $domDocument->appendChild($newNode);
91
92         return trim($domDocument->saveHTML());
93     }
94 }