protected static function JsonBlueprintDenormalizer::arrayIsKeyed in Subrequests 3.x
Same name and namespace in other branches
- 8.2 src/Normalizer/JsonBlueprintDenormalizer.php \Drupal\subrequests\Normalizer\JsonBlueprintDenormalizer::arrayIsKeyed()
- 8 src/Normalizer/JsonBlueprintDenormalizer.php \Drupal\subrequests\Normalizer\JsonBlueprintDenormalizer::arrayIsKeyed()
Check if an array is keyed.
Parameters
array $input: The input array to check.
Return value
bool True if the array is keyed.
1 call to JsonBlueprintDenormalizer::arrayIsKeyed()
File
- src/Normalizer/ JsonBlueprintDenormalizer.php, line 100 
Class
- JsonBlueprintDenormalizer
- Denormalizer that builds the blueprint based on the incoming blueprint.
Namespace
Drupal\subrequests\NormalizerCode
protected static function arrayIsKeyed(array $input) {
  $keys = array_keys($input);
  // If the array does not start at 0, it is not numeric.
  if ($keys[0] !== 0) {
    return TRUE;
  }
  // If there is a non-numeric key, the array is not numeric.
  $numeric_keys = array_filter($keys, 'is_numeric');
  if (count($keys) != count($numeric_keys)) {
    return TRUE;
  }
  // If the keys are not following the natural numbers sequence, then it is
  // not numeric.
  for ($index = 1; $index < count($keys); $index++) {
    if ($keys[$index] - $keys[$index - 1] !== 1) {
      return TRUE;
    }
  }
  return FALSE;
}