<?php
 namespace MongoDB\Model;
 use ArrayObject;
 use JsonSerializable;
 use MongoDB\BSON\Serializable;
 use MongoDB\BSON\Unserializable;
 use function MongoDB\recursive_copy;
 class BSONDocument extends ArrayObject implements JsonSerializable, Serializable, Unserializable {
 public function __clone() {
 foreach ($this as $key => $value) {
 $this[$key] = recursive_copy($value);
 }
 }
 public function __construct($input = [], $flags = ArrayObject::ARRAY_AS_PROPS, $iterator_class = 'ArrayIterator') {
 parent::__construct($input, $flags, $iterator_class);
 }
 public static function __set_state(array $properties) {
 $document = new static();
 $document->exchangeArray($properties);
 return $document;
 }
 public function bsonSerialize() {
 return (object) $this->getArrayCopy();
 }
 public function bsonUnserialize(array $data) {
 parent::__construct($data, ArrayObject::ARRAY_AS_PROPS);
 }
 public function jsonSerialize() {
 return (object) $this->getArrayCopy();
 }
 }
 