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

Breadcrumb

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

class Fields

Same name in this branch
  1. 11.1.x vendor/ramsey/uuid/src/Guid/Fields.php \Ramsey\Uuid\Guid\Fields
  2. 11.1.x vendor/ramsey/uuid/src/Rfc4122/Fields.php \Ramsey\Uuid\Rfc4122\Fields
  3. 11.1.x core/modules/views/src/Plugin/views/row/Fields.php \Drupal\views\Plugin\views\row\Fields

Nonstandard UUID fields do not conform to the RFC 4122 standard

Since some systems may create nonstandard UUIDs, this implements the Rfc4122\FieldsInterface, so that functionality of a nonstandard UUID is not degraded, in the event these UUIDs are expected to contain RFC 4122 fields.

Internally, this class represents the fields together as a 16-byte binary string.

@psalm-immutable

Hierarchy

  • class \Ramsey\Uuid\Nonstandard\Fields implements \Ramsey\Uuid\Rfc4122\FieldsInterface uses \Ramsey\Uuid\Fields\SerializableFieldsTrait, \Ramsey\Uuid\Rfc4122\VariantTrait

Expanded class hierarchy of Fields

47 string references to 'Fields'
AddFormBase::buildEntityFormElement in core/modules/media_library/src/Form/AddFormBase.php
Builds the sub-form for setting required fields on a new media item.
CachePluginBase::getRowCacheKeys in core/modules/views/src/Plugin/views/cache/CachePluginBase.php
Returns the row cache keys.
Collection::getCompositeOption in vendor/symfony/validator/Constraints/Collection.php
Returns the name of the property that contains the nested constraints.
Collection::getRequiredOptions in vendor/symfony/validator/Constraints/Collection.php
Returns the name of the required options.
Comment::rowStyleOptions in core/modules/comment/src/Plugin/views/wizard/Comment.php
Retrieves row style plugin names.

... See full list

File

vendor/ramsey/uuid/src/Nonstandard/Fields.php, line 45

Namespace

Ramsey\Uuid\Nonstandard
View source
final class Fields implements FieldsInterface {
    use SerializableFieldsTrait;
    use VariantTrait;
    
    /**
     * @param string $bytes A 16-byte binary string representation of a UUID
     *
     * @throws InvalidArgumentException if the byte string is not exactly 16 bytes
     */
    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');
        }
    }
    public function getBytes() : string {
        return $this->bytes;
    }
    public function getClockSeq() : Hexadecimal {
        $clockSeq = hexdec(bin2hex(substr($this->bytes, 8, 2))) & 0x3fff;
        return new Hexadecimal(str_pad(dechex($clockSeq), 4, '0', STR_PAD_LEFT));
    }
    public function getClockSeqHiAndReserved() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 8, 1)));
    }
    public function getClockSeqLow() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 9, 1)));
    }
    public function getNode() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 10)));
    }
    public function getTimeHiAndVersion() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 6, 2)));
    }
    public function getTimeLow() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 0, 4)));
    }
    public function getTimeMid() : Hexadecimal {
        return new Hexadecimal(bin2hex(substr($this->bytes, 4, 2)));
    }
    public function getTimestamp() : Hexadecimal {
        return new Hexadecimal(sprintf('%03x%04s%08s', hexdec($this->getTimeHiAndVersion()
            ->toString()) & 0xfff, $this->getTimeMid()
            ->toString(), $this->getTimeLow()
            ->toString()));
    }
    public function getVersion() : ?int {
        return null;
    }
    public function isNil() : bool {
        return false;
    }
    public function isMax() : bool {
        return false;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Fields::getBytes public function Returns the bytes that comprise the fields Overrides SerializableFieldsTrait::getBytes
Fields::getClockSeq public function Returns the full 16-bit clock sequence, with the variant bits (two most
significant bits) masked out
Overrides FieldsInterface::getClockSeq
Fields::getClockSeqHiAndReserved public function Returns the high field of the clock sequence multiplexed with the variant Overrides FieldsInterface::getClockSeqHiAndReserved
Fields::getClockSeqLow public function Returns the low field of the clock sequence Overrides FieldsInterface::getClockSeqLow
Fields::getNode public function Returns the node field Overrides FieldsInterface::getNode
Fields::getTimeHiAndVersion public function Returns the high field of the timestamp multiplexed with the version Overrides FieldsInterface::getTimeHiAndVersion
Fields::getTimeLow public function Returns the low field of the timestamp Overrides FieldsInterface::getTimeLow
Fields::getTimeMid public function Returns the middle field of the timestamp Overrides FieldsInterface::getTimeMid
Fields::getTimestamp public function Returns the full 60-bit timestamp, without the version Overrides FieldsInterface::getTimestamp
Fields::getVersion public function Returns the version Overrides FieldsInterface::getVersion
Fields::isMax public function
Fields::isNil public function Returns true if these fields represent a nil UUID Overrides FieldsInterface::isNil
Fields::__construct public function Overrides SerializableFieldsTrait::__construct
SerializableFieldsTrait::serialize public function Returns a string representation of object
SerializableFieldsTrait::unserialize public function Constructs the object from a serialized string representation
SerializableFieldsTrait::__serialize public function
SerializableFieldsTrait::__unserialize public function @psalm-suppress UnusedMethodCall
VariantTrait::getVariant public function Returns the variant identifier, according to RFC 4122, for the given bytes

API Navigation

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