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

Breadcrumb

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

class GenericNumberConverter

GenericNumberConverter uses the provided calculator to convert decimal numbers to and from hexadecimal values

@psalm-immutable

Hierarchy

  • class \Ramsey\Uuid\Converter\Number\GenericNumberConverter implements \Ramsey\Uuid\Converter\NumberConverterInterface

Expanded class hierarchy of GenericNumberConverter

2 files declare their use of GenericNumberConverter
BuilderCollection.php in vendor/ramsey/uuid/src/Builder/BuilderCollection.php
FeatureSet.php in vendor/ramsey/uuid/src/FeatureSet.php

File

vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php, line 27

Namespace

Ramsey\Uuid\Converter\Number
View source
class GenericNumberConverter implements NumberConverterInterface {
    public function __construct(CalculatorInterface $calculator) {
    }
    
    /**
     * @inheritDoc
     * @psalm-pure
     * @psalm-return numeric-string
     * @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
     * @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
     */
    public function fromHex(string $hex) : string {
        return $this->calculator
            ->fromBase($hex, 16)
            ->toString();
    }
    
    /**
     * @inheritDoc
     * @psalm-pure
     * @psalm-return non-empty-string
     * @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
     * @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
     */
    public function toHex(string $number) : string {
        
        /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
        return $this->calculator
            ->toBase(new IntegerObject($number), 16);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
GenericNumberConverter::fromHex public function @inheritDoc
@psalm-pure
@psalm-return numeric-string
@psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
@psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
Overrides NumberConverterInterface::fromHex
GenericNumberConverter::toHex public function @inheritDoc
@psalm-pure
@psalm-return non-empty-string
@psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
@psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
Overrides NumberConverterInterface::toHex
GenericNumberConverter::__construct public function

API Navigation

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