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

Breadcrumb

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

class StaticNodeProvider

StaticNodeProvider provides a static node value with the multicast bit set

@link http://tools.ietf.org/html/rfc4122#section-4.5 RFC 4122, ยง 4.5: Node IDs that Do Not Identify the Host

Hierarchy

  • class \Ramsey\Uuid\Provider\Node\StaticNodeProvider implements \Ramsey\Uuid\Provider\NodeProviderInterface

Expanded class hierarchy of StaticNodeProvider

File

vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php, line 33

Namespace

Ramsey\Uuid\Provider\Node
View source
class StaticNodeProvider implements NodeProviderInterface {
    private Hexadecimal $node;
    
    /**
     * @param Hexadecimal $node The static node value to use
     */
    public function __construct(Hexadecimal $node) {
        if (strlen($node->toString()) > 12) {
            throw new InvalidArgumentException('Static node value cannot be greater than 12 hexadecimal characters');
        }
        $this->node = $this->setMulticastBit($node);
    }
    public function getNode() : Hexadecimal {
        return $this->node;
    }
    
    /**
     * Set the multicast bit for the static node value
     */
    private function setMulticastBit(Hexadecimal $node) : Hexadecimal {
        $nodeHex = str_pad($node->toString(), 12, '0', STR_PAD_LEFT);
        $firstOctet = substr($nodeHex, 0, 2);
        $firstOctet = str_pad(dechex(hexdec($firstOctet) | 0x1), 2, '0', STR_PAD_LEFT);
        return new Hexadecimal($firstOctet . substr($nodeHex, 2));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
StaticNodeProvider::$node private property
StaticNodeProvider::getNode public function Returns a node ID Overrides NodeProviderInterface::getNode
StaticNodeProvider::setMulticastBit private function Set the multicast bit for the static node value
StaticNodeProvider::__construct public function

API Navigation

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