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

Breadcrumb

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

function Fields::__construct

Same name in this branch
  1. 11.1.x vendor/ramsey/uuid/src/Nonstandard/Fields.php \Ramsey\Uuid\Nonstandard\Fields::__construct()
  2. 11.1.x vendor/ramsey/uuid/src/Guid/Fields.php \Ramsey\Uuid\Guid\Fields::__construct()

Parameters

string $bytes A 16-byte binary string representation of a UUID:

Throws

InvalidArgumentException if the byte string is not exactly 16 bytes

InvalidArgumentException if the byte string does not represent an RFC 4122 UUID

InvalidArgumentException if the byte string does not contain a valid version

Overrides SerializableFieldsTrait::__construct

File

vendor/ramsey/uuid/src/Rfc4122/Fields.php, line 56

Class

Fields
RFC 4122 variant UUIDs are comprised of a set of named fields

Namespace

Ramsey\Uuid\Rfc4122

Code

public function __construct(string $bytes) {
    if (strlen($this->bytes) !== 16) {
        throw new InvalidArgumentException('The byte string must be 16 bytes long; ' . 'received ' . strlen($this->bytes) . ' bytes');
    }
    if (!$this->isCorrectVariant()) {
        throw new InvalidArgumentException('The byte string received does not conform to the RFC 4122 variant');
    }
    if (!$this->isCorrectVersion()) {
        throw new InvalidArgumentException('The byte string received does not contain a valid RFC 4122 version');
    }
}

API Navigation

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