| 1 | <?php |
||
| 7 | class Document implements JsonSerializable |
||
| 8 | { |
||
| 9 | protected $id; |
||
| 10 | protected $data; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Constructor |
||
| 14 | * |
||
| 15 | * @param array $data |
||
| 16 | * @param mixed $id |
||
| 17 | */ |
||
| 18 | public function __construct(array $data = [], $id = null) |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Returns a value of the document |
||
| 26 | * |
||
| 27 | * @param string $name |
||
| 28 | * |
||
| 29 | * @return mixed |
||
| 30 | */ |
||
| 31 | public function __get($name) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Create/edit a value |
||
| 38 | * |
||
| 39 | * @param string $name |
||
| 40 | * @param mixed $value |
||
| 41 | */ |
||
| 42 | public function __set($name, $value) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @see JsonSerializable |
||
| 49 | * |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | public function jsonSerialize() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Set a new id for the document |
||
| 59 | * |
||
| 60 | * @param mixed $id |
||
| 61 | * |
||
| 62 | * @return self |
||
| 63 | */ |
||
| 64 | public function setId($id) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Returns the document id |
||
| 73 | * |
||
| 74 | * @return mixed |
||
| 75 | */ |
||
| 76 | public function getId() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Returns the document data |
||
| 83 | * |
||
| 84 | * @return array |
||
| 85 | */ |
||
| 86 | public function getData() |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Change the document data |
||
| 93 | * |
||
| 94 | * @param array $data |
||
| 95 | * |
||
| 96 | * @return self |
||
| 97 | */ |
||
| 98 | public function setData(array $data) |
||
| 104 | } |
||
| 105 |