You are here

public static function SchemaMetatagManager::explode in Schema.org Metatag 8.2

Same name and namespace in other branches
  1. 8 src/SchemaMetatagManager.php \Drupal\schema_metatag\SchemaMetatagManager::explode()

Explode values if this is a multiple value field.

Parameters

string $value: The value to explode.

Return value

array The array of values.

Overrides SchemaMetatagManagerInterface::explode

1 call to SchemaMetatagManager::explode()
SchemaMetatagManagerTest::testExplode in tests/src/Unit/SchemaMetatagManagerTest.php
@covers ::explode @dataProvider stringData

File

src/SchemaMetatagManager.php, line 170

Class

SchemaMetatagManager
The SchemaMetatag Manager.

Namespace

Drupal\schema_metatag

Code

public static function explode($value) {
  if (is_string($value)) {
    $value = explode(',', $value);
  }
  if (is_array($value)) {
    $value = array_map('trim', $value);
    if (count($value) == 1) {
      return $value[0];
    }
  }
  return $value;
}