From 79648fddcce493f49624506ac7f9a01002a65de2 Mon Sep 17 00:00:00 2001 From: stiivo Date: Wed, 19 Jul 2023 23:14:06 +0200 Subject: [PATCH] fix(schemaorg): Enumeration type detection improved (#401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Enumeration type detection improved by traversing the graph and checking if one of the parent elements is of type schema.org/Enumeration * Update src/Schema/Model/Class_.php Co-authored-by: Alan Poulain * Update src/Schema/Model/Class_.php Co-authored-by: Alan Poulain * Update src/Schema/Model/Class_.php Co-authored-by: Alan Poulain * removed PHPDoc * fix CS --------- Co-authored-by: steven Co-authored-by: Alan Poulain Co-authored-by: Kévin Dunglas --- src/Schema/Model/Class_.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Schema/Model/Class_.php b/src/Schema/Model/Class_.php index 24118617..6d6a49b7 100644 --- a/src/Schema/Model/Class_.php +++ b/src/Schema/Model/Class_.php @@ -66,10 +66,10 @@ public function getSubClassOf(): array return array_filter($this->resource->all('rdfs:subClassOf', 'resource'), static fn (RdfResource $resource) => !$resource->isBNode()); } - public function isEnum(): bool + public function isEnum(RdfResource $resource = null): bool { - $subClassOf = $this->resource->get('rdfs:subClassOf'); + $parentClass = ($resource ?? $this->resource)->get('rdfs:subClassOf'); - return $subClassOf && self::SCHEMA_ORG_ENUMERATION === $subClassOf->getUri(); + return $parentClass && (self::SCHEMA_ORG_ENUMERATION === $parentClass->getUri() || $this->isEnum($parentClass)); } }