public function __construct(UuidFactory
$factory = null
) { $this->factory =
$factory ??
new UuidFactory();
parent::
__construct();
} protected function configure(): void
{ $this ->
setDefinition([ new InputOption('time-based', null, InputOption::VALUE_REQUIRED, 'The timestamp, to generate a time-based UUID: a parsable date/time string'
),
new InputOption('node', null, InputOption::VALUE_REQUIRED, 'The UUID whose node part should be used as the node of the generated UUID'
),
new InputOption('name-based', null, InputOption::VALUE_REQUIRED, 'The name, to generate a name-based UUID'
),
new InputOption('namespace', null, InputOption::VALUE_REQUIRED, 'The UUID to use at the namespace for named-based UUIDs, predefined namespaces keywords "dns", "url", "oid" and "x500" are accepted'
),
new InputOption('random-based', null, InputOption::VALUE_NONE, 'To generate a random-based UUID'
),
new InputOption('count', 'c', InputOption::VALUE_REQUIRED, 'The number of UUID to generate', 1
),
new InputOption('format', 'f', InputOption::VALUE_REQUIRED,
sprintf('The UUID output format ("%s")',
implode('", "',
$this->
getAvailableFormatOptions())), 'rfc4122'
),
]) ->
setHelp(<<<'EOF'
The <info>%command.name%</info> generates a UUID.
<info>php %command.full_name%</info>
To generate a time-based UUID:
<info>php %command.full_name% --time-based=now</info>
To specify a time-based UUID's node:
<info>php %command.full_name% --time-based=@1613480254 --node=fb3502dc-137e-4849-8886-ac90d07f64a7</info>
To generate a name-based UUID:
<info>php %command.full_name% --name-based=foo</info>
To specify a name-based UUID's namespace:
<info>php %command.full_name% --name-based=bar --namespace=fb3502dc-137e-4849-8886-ac90d07f64a7</info>
To generate a random-based UUID:
<info>php %command.full_name% --random-based</info>
To generate several UUIDs:
<info>php %command.full_name% --count=10</info>
To output a specific format:
<info>php %command.full_name% --format=base58</info>