Пример #1
0
 /**
  * {@inheritDoc}
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $uuids = array();
     $count = filter_var($input->getOption('count'), FILTER_VALIDATE_INT, array('default' => 1, 'min_range' => 1));
     if ((bool) $input->getOption('guid') == true) {
         $features = new FeatureSet(true);
         Uuid::setFactory(new UuidFactory($features));
     }
     if ((bool) $input->getOption('comb') === true) {
         Uuid::getFactory()->setRandomGenerator(new CombGenerator(Uuid::getFactory()->getRandomGenerator(), Uuid::getFactory()->getNumberConverter()));
     }
     for ($i = 0; $i < $count; $i++) {
         $uuids[] = $this->createUuid($input->getArgument('version'), $input->getArgument('namespace'), $input->getArgument('name'));
     }
     foreach ($uuids as $uuid) {
         $output->writeln((string) $uuid);
     }
 }
Пример #2
0
 /**
  * Verify that the factory is made global.
  *
  * @covers ::boot
  */
 public function testGlobalFactory()
 {
     $this->load(['uuid_factory' => ['global' => true]]);
     $this->bundle->boot();
     self::assertSame($this->container->get('kherge_uuid.uuid_factory'), Uuid::getFactory());
 }
Пример #3
0
 /**
  * Make sure the returned instance is a Rhumsaa\Uuid\Uuid which inherit
  * from the Ramsey namespace.
  *
  * This is mandatory when using type hint in function and you want your
  * function works with both namespaces.
  *
  * @param \Ramsey\Uuid\Uuid $uuid
  *
  * @return Uuid
  */
 private static function fromRamseyUuid(\Ramsey\Uuid\Uuid $uuid)
 {
     return new self($uuid->getFieldsHex(), $uuid->getNumberConverter(), \Ramsey\Uuid\Uuid::getFactory()->getCodec());
 }