Skip to content

Commit

Permalink
Merge 3f35c72 into ffbf91d
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlaak committed Nov 26, 2019
2 parents ffbf91d + 3f35c72 commit 75d8915
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Micrometa/Infrastructure/Parser/JsonLD.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,23 @@ protected function parseNode(NodeInterface $node)
*
* @return array Item type
*/
protected function parseNodeType(NodeInterface $node)
protected function parseNodeType(NodeInterface $node): array
{
/** @var Node $itemType */
return ($itemType = $node->getType()) ? [$this->vocabularyCache->expandIRI($itemType->getId())] : [];
/** @var NodeInterface|NodeInterface[] $itemTypes */
$itemTypes = $node->getType();
$itemTypes = is_array($itemTypes) ? $itemTypes : [$itemTypes];
$itemTypes = array_filter($itemTypes);

if (empty($itemTypes)) {
return [];
}

$types = [];
foreach ($itemTypes as $itemType) {
$types[] = $this->vocabularyCache->expandIRI($itemType->getId());
}

return $types;
}

/**
Expand Down

0 comments on commit 75d8915

Please sign in to comment.