1 | <?php |
||
19 | abstract class AbstractDocument implements DocumentInterface |
||
20 | { |
||
21 | /** |
||
22 | * default fields |
||
23 | * @const array DEFAULT_FIELDS |
||
24 | */ |
||
25 | const DEFAULT_FIELDS = ['createdAt']; |
||
26 | |||
27 | /** |
||
28 | * created at |
||
29 | * @param int $createdAt |
||
30 | */ |
||
31 | protected $createdAt = null; |
||
32 | |||
33 | /** |
||
34 | * get fields |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | abstract protected function getFields(): array; |
||
39 | |||
40 | /** |
||
41 | * set created at |
||
42 | * |
||
43 | * @param int $createdAt |
||
44 | * |
||
45 | * @return this |
||
46 | */ |
||
47 | 9 | public function setCreatedAt($createdAt) |
|
53 | |||
54 | /** |
||
55 | * get created at |
||
56 | * |
||
57 | * @return int |
||
58 | */ |
||
59 | 9 | public function getCreatedAt(): int |
|
63 | |||
64 | /** |
||
65 | * to json |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | 8 | public function toJson(): string |
|
81 | |||
82 | /** |
||
83 | * to snake case |
||
84 | * |
||
85 | * @param string $string |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 8 | protected function toSnakeCase(string $string): string |
|
93 | } |
||
94 |