Yoast\WP\SEO\Schema_Aggregator\Application
Properties_Merger::normalize_type_from_array
Normalize array of types back to string or array.
Returns string if single type, array if multiple types. This keeps the output compact while supporting multi-type entities.
Метод класса: Properties_Merger{}
Хуков нет.
Возвращает
string|array<string>. Normalized type value.
Использование
// private - только в коде основоного (родительского) класса $result = $this->normalize_type_from_array( $types );
- $types(array
) (обязательный) - Array of type strings.
Код Properties_Merger::normalize_type_from_array() Properties Merger::normalize type from array Yoast 28.8
private function normalize_type_from_array( array $types ) {
// Remove duplicates and re-index.
$types = \array_values( \array_unique( $types ) );
if ( empty( $types ) ) {
// Fallback - should not happen in normal flow.
return 'Thing'; // schema.org root type.
}
if ( \count( $types ) === 1 ) {
return $types[0];
}
return $types;
}