$metadataValueCollection) { /** @var ImsManifestMetadataValue $metadataValue */ foreach ($metadataValueCollection as $key => $metadataValue) { // If metadata is not a source or is empty then skip if ($metadataValue->getValue() === '' || $metadataValue->getPath() !== ClassificationSourceMetadataValue::getSourcePath()) { continue; } // If next metadata does not exist then skip if (! isset($metadataValueCollection[$key + 1])) { continue; } /** @var MetadataValue $entryMetadata */ $entryMetadata = $metadataValueCollection[$key + 1]; // Handle metadata if it is an entry and is not empty if ($entryMetadata->getPath() === ClassificationEntryMetadataValue::getEntryPath() && $entryMetadata->getValue() !== '') { $newValues[$resourceIdentifier][] = new SimpleMetadataValue( $resourceIdentifier, [LomMetadata::LOM_NAMESPACE . '#lom', $metadataValue->getValue()], $entryMetadata->getValue() ); } } } return $newValues; } }