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

Breadcrumb

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

class FallbackBuilder

FallbackBuilder builds a UUID by stepping through a list of UUID builders until a UUID can be constructed without exceptions

@psalm-immutable

Hierarchy

  • class \Ramsey\Uuid\Builder\FallbackBuilder implements \Ramsey\Uuid\Builder\UuidBuilderInterface

Expanded class hierarchy of FallbackBuilder

1 file declares its use of FallbackBuilder
FeatureSet.php in vendor/ramsey/uuid/src/FeatureSet.php

File

vendor/ramsey/uuid/src/Builder/FallbackBuilder.php, line 28

Namespace

Ramsey\Uuid\Builder
View source
class FallbackBuilder implements UuidBuilderInterface {
    
    /**
     * @param iterable<UuidBuilderInterface> $builders An array of UUID builders
     */
    public function __construct(iterable $builders) {
    }
    
    /**
     * Builds and returns a UuidInterface instance using the first builder that
     * succeeds
     *
     * @param CodecInterface $codec The codec to use for building this instance
     * @param string $bytes The byte string from which to construct a UUID
     *
     * @return UuidInterface an instance of a UUID object
     *
     * @psalm-pure
     */
    public function build(CodecInterface $codec, string $bytes) : UuidInterface {
        $lastBuilderException = null;
        foreach ($this->builders as $builder) {
            try {
                return $builder->build($codec, $bytes);
            } catch (UnableToBuildUuidException $exception) {
                $lastBuilderException = $exception;
                continue;
            }
        }
        throw new BuilderNotFoundException('Could not find a suitable builder for the provided codec and fields', 0, $lastBuilderException);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
FallbackBuilder::build public function Builds and returns a UuidInterface instance using the first builder that
succeeds
Overrides UuidBuilderInterface::build
FallbackBuilder::__construct public function

API Navigation

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