1: <?php
2: namespace Datadepo\Api\Structures;
3:
4: /**
5: * @property-read string $json
6: * @property-read string $checksum
7: * @property-read string $primary
8: * @property-read array $data
9: */
10: abstract class AbstractStructure
11: {
12:
13: /** @var string */
14: protected $json;
15:
16: /** @var \stdClass */
17: protected $data;
18:
19: /**
20: * @param string $json
21: */
22: public function __construct($json)
23: {
24: $this->json = $json;
25: $this->data = json_decode($this->json);
26: }
27:
28: /**
29: * @return string
30: */
31: public function getPrimary()
32: {
33: return NULL;
34: }
35:
36: /**
37: * @return \stdClass
38: */
39: public function getData()
40: {
41: return $this->data;
42: }
43:
44: /**
45: * @return string
46: */
47: public function getJson()
48: {
49: return $this->json;
50: }
51:
52: /**
53: * @return string
54: */
55: public function getChecksum()
56: {
57: return md5($this->json);
58: }
59:
60: /**
61: * @param string $name
62: * @return mixed
63: */
64: public function __get($name)
65: {
66: return $this->{'get' . $name}();
67: }
68:
69: }