Skip to content

Commit

Permalink
fix(schemaorg): Enumeration type detection improved (#401)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update src/Schema/Model/Class_.php

Co-authored-by: Alan Poulain <[email protected]>

* Update src/Schema/Model/Class_.php

Co-authored-by: Alan Poulain <[email protected]>

* removed PHPDoc

* fix CS

---------

Co-authored-by: steven <[email protected]>
Co-authored-by: Alan Poulain <[email protected]>
Co-authored-by: Kévin Dunglas <[email protected]>
  • Loading branch information
4 people authored Jul 19, 2023
1 parent 1d24727 commit 79648fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Schema/Model/Class_.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 79648fd

Please sign in to comment.