Skip to content

Commit ea98ddd

Browse files
committed
Se agrega serialización JSON para XmlDocument.
1 parent 583e09e commit ea98ddd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/Contract/XmlDocumentInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
use Derafu\Xml\Exception\XmlException;
1616
use DOMNode;
1717
use DOMNodeList;
18+
use JsonSerializable;
1819

1920
/**
2021
* Interface for the class that represents an XML document.
2122
*/
22-
interface XmlDocumentInterface extends DOMDocumentInterface
23+
interface XmlDocumentInterface extends DOMDocumentInterface, JsonSerializable
2324
{
2425
/**
2526
* Returns the name of the root tag of the XML.

src/XmlDocument.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,12 @@ public function getDocumentElement(): ?DOMElement
296296
{
297297
return $this->documentElement;
298298
}
299+
300+
/**
301+
* {@inheritDoc}
302+
*/
303+
public function jsonSerialize(): array
304+
{
305+
return $this->toArray();
306+
}
299307
}

0 commit comments

Comments
 (0)