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

Breadcrumb

  1. Drupal Core 11.1.x

ClassConstantAccessor.php

Namespace

OpenTelemetry\SDK\Common\Util

File

vendor/open-telemetry/sdk/Common/Util/ClassConstantAccessor.php

View source
<?php

declare (strict_types=1);
namespace OpenTelemetry\SDK\Common\Util;

use LogicException;
class ClassConstantAccessor {
    public static function requireValue(string $className, string $constantName) {
        $constant = self::getFullName($className, $constantName);
        if (!defined($constant)) {
            throw new LogicException(sprintf('The class "%s" does not have a constant "%s"', $className, $constantName));
        }
        return constant($constant);
    }
    public static function getValue(string $className, string $constantName) {
        $constant = self::getFullName($className, $constantName);
        return defined($constant) ? constant($constant) : null;
    }
    private static function getFullName(string $className, string $constantName) : string {
        return $className . '::' . $constantName;
    }

}

Classes

Title Deprecated Summary
ClassConstantAccessor

API Navigation

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