Skip to content

Commit

Permalink
validation for datePublished and dateModified in case of them behing …
Browse files Browse the repository at this point in the history
…null
  • Loading branch information
marcelosantos89 authored Feb 28, 2024
1 parent 2856dd0 commit 9d1d02d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Schema/ArticleSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public function generateInner(): string
'@type' => 'WebPage',
'@id' => $this->url,
],
'datePublished' => $this->datePublished->toIso8601String(),
'dateModified' => $this->dateModified->toIso8601String(),
'datePublished' => $this->datePublished?->toIso8601String(),
'dateModified' => $this->dateModified?->toIso8601String(),
'headline' => $this->headline,
])
->when($this->authors, fn (Collection $collection): Collection => $collection->put('author', $this->authors))
Expand All @@ -95,4 +95,4 @@ public function generateInner(): string
->pipeThrough($this->markupTransformers)
->toJson();
}
}
}

0 comments on commit 9d1d02d

Please sign in to comment.