|
12 | 12 | class Database extends Entity |
13 | 13 | { |
14 | 14 | private string $title = ""; |
15 | | - private array $rawTitle = []; |
| 15 | + private array $rawTitle = []; // toDo why "raw"title? |
16 | 16 | private array $rawProperties = []; |
17 | 17 | private DateTime $createdTime; |
18 | 18 | private DateTime $lastEditedTime; |
19 | 19 |
|
| 20 | + // toDo Draft |
| 21 | + private array $responseData; |
| 22 | + |
| 23 | + |
20 | 24 | protected function setRaw(array $raw): void |
21 | 25 | { |
22 | 26 | parent::setRaw($raw); |
23 | 27 | if ($raw['object'] !== 'database') throw WrapperException::instance("invalid json-array: the given object is not a database"); |
24 | 28 |
|
25 | | - if (Arr::exists($raw, 'title') && is_array($raw['title'])) { |
26 | | - $this->title = Arr::first($raw['title'], null, ['plain_text' => ''])['plain_text']; |
27 | | - $this->rawTitle = $raw['title']; |
28 | | - } |
29 | | - |
30 | | - if (Arr::exists($raw, 'properties')) { |
31 | | - $this->rawProperties = $raw['properties']; |
32 | | - } |
| 29 | + //toDo Draft |
| 30 | + $this->responseData = $raw; |
| 31 | + |
| 32 | + $this->fillFromRaw(); |
| 33 | + |
| 34 | +// if (Arr::exists($raw, 'title') && is_array($raw['title'])) { |
| 35 | +// $this->title = Arr::first($raw['title'], null, ['plain_text' => ''])['plain_text']; |
| 36 | +// $this->rawTitle = $raw['title']; |
| 37 | +// } |
| 38 | +// |
| 39 | +// if (Arr::exists($raw, 'properties')) { |
| 40 | +// $this->rawProperties = $raw['properties']; |
| 41 | +// } |
| 42 | +// |
| 43 | +// if (Arr::exists($raw, 'created_time')) { |
| 44 | +// $this->createdTime = new Carbon($raw['created_time']); |
| 45 | +// } |
| 46 | +// |
| 47 | +// if (Arr::exists($raw, 'last_edited_time')) { |
| 48 | +// $this->lastEditedTime = new Carbon($raw['last_edited_time']); |
| 49 | +// } |
| 50 | + } |
| 51 | + //toDo Draft |
33 | 52 |
|
34 | | - if (Arr::exists($raw, 'created_time')) { |
35 | | - $this->createdTime = new Carbon($raw['created_time']); |
36 | | - } |
| 53 | + private function fillFromRaw() |
| 54 | + { |
| 55 | + $this->fillTitle(); |
| 56 | + } |
37 | 57 |
|
38 | | - if (Arr::exists($raw, 'last_edited_time')) { |
39 | | - $this->lastEditedTime = new Carbon($raw['last_edited_time']); |
| 58 | + private function fillTitle() |
| 59 | + { |
| 60 | + if (Arr::exists($this->responseData, 'title') && is_array($this->responseData['title'])) { |
| 61 | + $this->title = Arr::first($this->responseData['title'], null, ['plain_text' => ''])['plain_text']; |
| 62 | + $this->rawTitle = $this->responseData['title']; |
40 | 63 | } |
41 | 64 | } |
| 65 | + //toDo end Draft |
42 | 66 |
|
43 | 67 | public function getTitle(): string |
44 | 68 | { |
|
0 commit comments