File tree Expand file tree Collapse file tree 7 files changed +34
-49
lines changed
Expand file tree Collapse file tree 7 files changed +34
-49
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ protected function setResponseData(array $responseData): void
5959
6060 protected function fillFromRaw (): void
6161 {
62- $ this -> fillId ();
62+ parent :: fillEntityBase ();
6363 $ this ->fillType ();
6464 $ this ->fillRawContent ();
6565 $ this ->fillHasChildren ();
Original file line number Diff line number Diff line change @@ -53,11 +53,6 @@ class Database extends Entity
5353 */
5454 private string $ url ;
5555
56- /**
57- * @var string
58- */
59- protected string $ objectType = '' ;
60-
6156 /**
6257 * @var ?RichText
6358 */
@@ -104,13 +99,12 @@ protected function setResponseData(array $responseData): void
10499
105100 private function fillFromRaw ()
106101 {
107- $ this -> fillId ();
102+ parent :: fillEntityBase ();
108103 $ this ->fillIcon ();
109104 $ this ->fillCover ();
110105 $ this ->fillTitle ();
111106 $ this ->fillIsInline ();
112107 $ this ->fillDescription ();
113- $ this ->fillObjectType ();
114108 $ this ->fillProperties ();
115109 $ this ->fillDatabaseUrl ();
116110 $ this ->fillParentProperties ();
@@ -174,13 +168,6 @@ private function fillCover(): void
174168 }
175169 }
176170
177- private function fillObjectType (): void
178- {
179- if (Arr::exists ($ this ->responseData , 'object ' )) {
180- $ this ->objectType = $ this ->responseData ['object ' ];
181- }
182- }
183-
184171 private function fillProperties (): void
185172 {
186173 if (Arr::exists ($ this ->responseData , 'properties ' )) {
@@ -209,14 +196,6 @@ public function getProperty(string $propertyKey): ?Property
209196 return $ this ->propertyMap [$ propertyKey ];
210197 }
211198
212- /**
213- * @return string
214- */
215- public function getObjectType (): string
216- {
217- return $ this ->objectType ;
218- }
219-
220199 /**
221200 * @return string
222201 */
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ class Entity implements JsonSerializable
1717 */
1818 private string $ id ;
1919
20+ /**
21+ * @var string
22+ */
23+ protected string $ objectType = '' ;
24+
2025 /**
2126 * @var array
2227 */
@@ -67,11 +72,24 @@ protected function setResponseData(array $responseData): void
6772 $ this ->responseData = $ responseData ;
6873 }
6974
70- protected function fillId ()
75+ protected function fillEntityBase (): void
76+ {
77+ $ this ->fillId ();
78+ $ this ->fillObjectType ();
79+ }
80+
81+ private function fillId ()
7182 {
7283 $ this ->id = $ this ->responseData ['id ' ];
7384 }
7485
86+ private function fillObjectType (): void
87+ {
88+ if (Arr::exists ($ this ->responseData , 'object ' )) {
89+ $ this ->objectType = $ this ->responseData ['object ' ];
90+ }
91+ }
92+
7593 /**
7694 * @return string
7795 */
@@ -80,11 +98,20 @@ public function getId(): string
8098 return $ this ->id ;
8199 }
82100
101+
83102 public function setId ($ id ): void
84103 {
85104 $ this ->id = $ id ;
86105 }
87106
107+ /**
108+ * @return string
109+ */
110+ public function getObjectType (): string
111+ {
112+ return $ this ->objectType ;
113+ }
114+
88115 /**
89116 * @return array
90117 */
Original file line number Diff line number Diff line change @@ -60,11 +60,6 @@ class Page extends Entity
6060 */
6161 private string $ coverType = '' ;
6262
63- /**
64- * @var string
65- */
66- protected string $ objectType = '' ;
67-
6863 /**
6964 * @var array
7065 */
@@ -116,8 +111,7 @@ protected function setResponseData(array $responseData): void
116111
117112 private function fillFromRaw (): void
118113 {
119- $ this ->fillId ();
120- $ this ->fillObjectType ();
114+ parent ::fillEntityBase ();
121115 $ this ->fillProperties ();
122116 $ this ->fillTitle (); // This has to be called after fillProperties(), since title is provided by properties
123117 $ this ->fillPageUrl ();
@@ -128,13 +122,6 @@ private function fillFromRaw(): void
128122 $ this ->fillTimestampableProperties ();
129123 }
130124
131- private function fillObjectType (): void
132- {
133- if (Arr::exists ($ this ->responseData , 'object ' )) {
134- $ this ->objectType = $ this ->responseData ['object ' ];
135- }
136- }
137-
138125 /**
139126 * @throws HandlingException
140127 */
@@ -446,14 +433,6 @@ public function getProperty(string $propertyKey): ?Property
446433 return $ this ->propertyMap [$ propertyKey ];
447434 }
448435
449- /**
450- * @return string
451- */
452- public function getObjectType (): string
453- {
454- return $ this ->objectType ;
455- }
456-
457436 /**
458437 * @return array
459438 */
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ protected function setResponseData(array $responseData): void
6262
6363 protected function fillFromRaw (): void
6464 {
65- $ this -> fillId ();
65+ parent :: fillEntityBase ();
6666 $ this ->fillType ();
6767 $ this ->fillContent ();
6868 }
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ protected function setResponseData(array $responseData): void
3636
3737 protected function fillFromRaw (): void
3838 {
39- $ this -> fillId ();
39+ parent :: fillEntityBase ();
4040 $ this ->fillName ();
4141 $ this ->fillColor ();
4242 }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ protected function setResponseData(array $responseData): void
3737
3838 private function fillFromRaw (): void
3939 {
40- $ this -> fillId ();
40+ parent :: fillEntityBase ();
4141 $ this ->fillName ();
4242 $ this ->fillAvatarUrl ();
4343 }
You can’t perform that action at this time.
0 commit comments