@@ -93,7 +93,7 @@ public function __construct(
9393 public int $ versionCount ,
9494 public int $ versionOfCount ,
9595 public DateTimeImmutable $ created ,
96- public DateTimeImmutable $ registered ,
96+ public ? DateTimeImmutable $ registered ,
9797 public ?string $ published ,
9898 public DateTimeImmutable $ updated ,
9999 public RelationshipData $ relationships ,
@@ -204,10 +204,13 @@ public static function fromArray(array $data): self
204204 $ publisherData = PublisherData::fromArray ($ publisherArray );
205205 }
206206
207- $ creators = array_map (
208- fn (array $ item ): Creator => Creator::fromArray ($ item ),
209- $ creatorsData
210- );
207+ $ creators = array_values (array_filter (
208+ array_map (
209+ fn (array $ item ): ?Creator => Creator::fromArray ($ item ),
210+ $ creatorsData
211+ ),
212+ fn (?Creator $ creator ): bool => $ creator instanceof \VincentAuger \DataCiteSdk \Data \Metadata \Creator
213+ ));
211214 assert ($ creators !== [], 'At least one creator is required ' );
212215
213216 $ titles = array_map (
@@ -239,10 +242,13 @@ public static function fromArray(array $data): self
239242 fn (array $ item ): Subject => Subject::fromArray ($ item ),
240243 $ subjectsData
241244 ),
242- contributors: array_map (
243- fn (array $ item ): Contributor => Contributor::fromArray ($ item ),
244- $ contributorsData
245- ),
245+ contributors: array_values (array_filter (
246+ array_map (
247+ fn (array $ item ): ?Contributor => Contributor::fromArray ($ item ),
248+ $ contributorsData
249+ ),
250+ fn (?Contributor $ contributor ): bool => $ contributor instanceof \VincentAuger \DataCiteSdk \Data \Metadata \Contributor
251+ )),
246252 dates: array_map (
247253 fn (array $ item ): Date => Date::fromArray ($ item ),
248254 $ datesData
@@ -264,10 +270,13 @@ public static function fromArray(array $data): self
264270 fn (array $ item ): RightsList => RightsList::fromArray ($ item ),
265271 $ rightsListData
266272 ),
267- descriptions: array_map (
268- fn (array $ item ): Description => Description::fromArray ($ item ),
269- $ descriptionsData
270- ),
273+ descriptions: array_values (array_filter (
274+ array_map (
275+ fn (array $ item ): ?Description => Description::fromArray ($ item ),
276+ $ descriptionsData
277+ ),
278+ fn (?Description $ description ): bool => $ description instanceof \VincentAuger \DataCiteSdk \Data \Metadata \Description
279+ )),
271280 geoLocations: array_map (
272281 fn (array $ item ): GeoLocation => GeoLocation::fromArray ($ item ),
273282 $ geoLocationsData
@@ -297,7 +306,9 @@ public static function fromArray(array $data): self
297306 versionCount: (int ) $ attributes ['versionCount ' ],
298307 versionOfCount: (int ) $ attributes ['versionOfCount ' ],
299308 created: new DateTimeImmutable ($ attributes ['created ' ]),
300- registered: new DateTimeImmutable ($ attributes ['registered ' ]),
309+ registered: empty ($ attributes ['registered ' ])
310+ ? null
311+ : new DateTimeImmutable ($ attributes ['registered ' ]),
301312 published: $ attributes ['published ' ] ?? null ,
302313 updated: new DateTimeImmutable ($ attributes ['updated ' ]),
303314 relationships: RelationshipData::fromArray ($ relationshipsData ),
0 commit comments