Skip to content

Commit f75aadd

Browse files
authored
Merge pull request #245 from Ashafaat/master
implementing JsonSerializable interface.
2 parents 5e2bb1e + 8989597 commit f75aadd

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/ArangoDBClient/Document.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @package ArangoDBClient
2020
* @since 0.2
2121
*/
22-
class Document
22+
class Document implements \JsonSerializable
2323
{
2424
/**
2525
* The document id (might be NULL for new documents)
@@ -773,6 +773,22 @@ public function getRevision()
773773
return $this->_rev;
774774
}
775775

776+
/**
777+
* Get all document attributes
778+
* Alias function for getAll() - it's necessary for implementing JsonSerializable interface
779+
*
780+
* @param mixed $options - optional, array of options for the getAll function, or the boolean value for $includeInternals
781+
* <p>Options are :
782+
* <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
783+
* <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
784+
* </p>
785+
*
786+
* @return array - array of all document attributes/values
787+
*/
788+
public function jsonSerialize(array $options = [])
789+
{
790+
return $this->getAll($options);
791+
}
776792
}
777793

778794
class_alias(Document::class, '\triagens\ArangoDb\Document');

0 commit comments

Comments
 (0)