You are here

public static function SchemaMetatagManager::countNumericKeys in Schema.org Metatag 8

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

If the item is an array with numeric keys, count the keys.

Overrides SchemaMetatagManagerInterface::countNumericKeys

2 calls to SchemaMetatagManager::countNumericKeys()
SchemaMetatagManager::isObject in src/SchemaMetatagManager.php
Is object?
SchemaMetatagManager::pivot in src/SchemaMetatagManager.php
Pivot multiple value results.

File

src/SchemaMetatagManager.php, line 155

Class

SchemaMetatagManager
Class SchemaMetatagManager.

Namespace

Drupal\schema_metatag

Code

public static function countNumericKeys($item) {
  if (!is_array($item)) {
    return 0;
  }
  foreach (array_keys($item) as $key) {
    if (!is_numeric($key)) {
      return 0;
    }
  }
  return count($item);
}