本文整理汇总了PHP中Ramsey\Uuid\Uuid::getFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::getFactory方法的具体用法?PHP Uuid::getFactory怎么用?PHP Uuid::getFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ramsey\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::getFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@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: testGlobalFactory
/**
* 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: fromRamseyUuid
/**
* 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());
}