vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of the ramsey/uuid library
  4.  *
  5.  * For the full copyright and license information, please view the LICENSE
  6.  * file that was distributed with this source code.
  7.  *
  8.  * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
  9.  * @license http://opensource.org/licenses/MIT MIT
  10.  * @link https://benramsey.com/projects/ramsey-uuid/ Documentation
  11.  * @link https://packagist.org/packages/ramsey/uuid Packagist
  12.  * @link https://github.com/ramsey/uuid GitHub
  13.  */
  14. namespace Ramsey\Uuid\Builder;
  15. use Ramsey\Uuid\Codec\CodecInterface;
  16. use Ramsey\Uuid\Converter\NumberConverterInterface;
  17. use Ramsey\Uuid\Uuid;
  18. /**
  19.  * DefaultUuidBuilder is the default UUID builder for ramsey/uuid; it builds
  20.  * instances of Uuid objects
  21.  */
  22. class DefaultUuidBuilder implements UuidBuilderInterface
  23. {
  24.     /**
  25.      * @var NumberConverterInterface
  26.      */
  27.     private $converter;
  28.     /**
  29.      * Constructs the DefaultUuidBuilder
  30.      *
  31.      * @param NumberConverterInterface $converter The number converter to use when constructing the Uuid
  32.      */
  33.     public function __construct(NumberConverterInterface $converter)
  34.     {
  35.         $this->converter $converter;
  36.     }
  37.     /**
  38.      * Builds a Uuid
  39.      *
  40.      * @param CodecInterface $codec The codec to use for building this Uuid
  41.      * @param array $fields An array of fields from which to construct the Uuid;
  42.      *     see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
  43.      * @return Uuid
  44.      */
  45.     public function build(CodecInterface $codec, array $fields)
  46.     {
  47.         return new Uuid($fields$this->converter$codec);
  48.     }
  49. }