From dbfbdcd94b4dc0f6abc4c23a7b81e3c86992e1f6 Mon Sep 17 00:00:00 2001 From: Quentin Gabriele Date: Fri, 13 Sep 2024 17:38:18 +0200 Subject: [PATCH] addSchema --- src/SeoManager.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/SeoManager.php b/src/SeoManager.php index 8f82840..cc497e3 100644 --- a/src/SeoManager.php +++ b/src/SeoManager.php @@ -42,7 +42,7 @@ public function current(): static } /** - * @param null|Standard|(Closure(Standard):null|Standard) $value + * @param null|Standard|(Closure(Standard):(null|Standard)) $value * @return $this */ public function setStandard(null|Standard|Closure $value): static @@ -57,7 +57,7 @@ public function setStandard(null|Standard|Closure $value): static } /** - * @param null|OpenGraph|(Closure(OpenGraph):null|OpenGraph) $value + * @param null|OpenGraph|(Closure(OpenGraph):(null|OpenGraph)) $value * @return $this */ public function setOpengraph(null|OpenGraph|Closure $value): static @@ -72,7 +72,7 @@ public function setOpengraph(null|OpenGraph|Closure $value): static } /** - * @param null|Card|(Closure(Card):null|Card) $value + * @param null|Card|(Closure(Card):(null|Card)) $value * @return $this */ public function setTwitter(null|Card|Closure $value): static @@ -87,7 +87,7 @@ public function setTwitter(null|Card|Closure $value): static } /** - * @param null|WebPage|(Closure(WebPage):null|WebPage) $value + * @param null|WebPage|(Closure(WebPage):(null|WebPage)) $value * @return $this */ public function setWebpage(null|WebPage|Closure $value): static @@ -101,6 +101,33 @@ public function setWebpage(null|WebPage|Closure $value): static return $this; } + /** + * @param null|Schema[]|(Closure(Schema[]):(null|Schema[])) $value + * @return $this + */ + public function setSchemas(null|array|Closure $value): static + { + if ($value instanceof Closure) { + $this->schemas = $value($this->schemas ?? []); + } else { + $this->schemas = $value; + } + + return $this; + } + + /** + * @return $this + */ + public function addSchema(Schema $value): static + { + return $this->setSchemas(function ($schemas) use ($value) { + $schemas[] = $value; + + return $schemas; + }); + } + public function setTitle(string $value): static { if ($this->standard) {