Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AttributeValidator.php

function AttributeValidator::validateArray

1 call to AttributeValidator::validateArray()
AttributeValidator::validate in vendor/open-telemetry/sdk/Common/Attribute/AttributeValidator.php
Validate whether a value is a primitive, or a homogeneous array of primitives (treating int/double as equivalent).

File

vendor/open-telemetry/sdk/Common/Attribute/AttributeValidator.php, line 33

Class

AttributeValidator

Namespace

OpenTelemetry\SDK\Common\Attribute

Code

private function validateArray(array $value) : bool {
    if ($value === []) {
        return true;
    }
    $type = gettype(reset($value));
    if (!in_array($type, self::PRIMITIVES)) {
        return false;
    }
    foreach ($value as $v) {
        if (in_array(gettype($v), self::NUMERICS) && in_array($type, self::NUMERICS)) {
            continue;
        }
        if (gettype($v) !== $type) {
            return false;
        }
    }
    return true;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal