本文整理汇总了PHP中Rhumsaa\Uuid\Uuid::uuid1方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::uuid1方法的具体用法?PHP Uuid::uuid1怎么用?PHP Uuid::uuid1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhumsaa\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::uuid1方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialize the saga. If an identifier is provided it will be used, otherwise a random UUID will be generated.
*
* @param string $identifier
*/
public function __construct($identifier = null)
{
$this->identifier = null === $identifier ? Uuid::uuid1()->toString() : $identifier;
$this->associationValues = new AssociationValuesImpl();
$this->inspector = new SagaMethodMessageHandlerInspector($this);
$this->associationValues->add(new AssociationValue('sagaIdentifier', $this->identifier));
}
示例2: createUuid
/**
* Creates the requested UUID
*
* @param int $version
* @param string $namespace
* @param string $name
* @return Uuid
*/
protected function createUuid($version, $namespace = null, $name = null)
{
switch ((int) $version) {
case 1:
$uuid = Uuid::uuid1();
break;
case 4:
$uuid = Uuid::uuid4();
break;
case 3:
case 5:
$ns = $this->validateNamespace($namespace);
if (empty($name)) {
throw new Exception('The name argument is required for version 3 or 5 UUIDs');
}
if ($version == 3) {
$uuid = Uuid::uuid3($ns, $name);
} else {
$uuid = Uuid::uuid5($ns, $name);
}
break;
default:
throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
}
return $uuid;
}
示例3: __construct
/**
* @param mixed $payload
* @param MetaData $metaData
* @param string|null $id
* @param string|null $commandName
*/
public function __construct($payload, MetaData $metaData = null, $id = null, $commandName = null)
{
$this->id = null === $id ? Uuid::uuid1()->toString() : $id;
$this->commandName = null === $commandName ? get_class($payload) : $commandName;
$this->payload = $payload;
$this->metaData = null === $metaData ? MetaData::emptyInstance() : $metaData;
}
示例4: login
public function login()
{
try {
$passwordMatch = false;
$userDeviceUpdated = false;
$access_token = '';
$input = Request::all();
$user = User::where('email', $input['email'])->first();
if ($user) {
if (crypt($input['password'], $user->password) == $user->password) {
$passwordMatch = true;
}
}
if ($passwordMatch) {
$userDevice = UserDevice::where('device_id', $input['device_id'])->first();
$access_token = Uuid::uuid1()->toString();
if ($userDevice) {
$userDeviceUpdated = $userDevice->update(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
} else {
$userDeviceUpdated = UserDevice::create(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
}
}
if ($userDeviceUpdated) {
$vendorLocationContact = VendorLocationContact::where('user_id', $user->id)->first();
$vendorLocation = VendorLocation::where('id', $vendorLocationContact->vendor_location_id)->first();
$vendor = Vendor::where('id', $vendorLocation->vendor_id)->first();
return response()->json(['id' => $user->id, 'access_token' => $access_token, 'full_name' => $user->full_name, 'email' => $user->email, 'phone_number' => $user->phone_number, 'role' => $user->role->name, 'vendor_name' => $vendor->name], 200);
} else {
return response()->json(['action' => 'Check if the email address and password match', 'message' => 'There is an email password mismatch. Please check and try again'], 227);
}
} catch (\Exception $e) {
return response()->json(['message' => 'An application error occured.', 'error' => $e->getMessage()], 500);
}
}
示例5: generate
public static function generate($ver = 4, $node = null, $clockSeq = null, $ns = null, $name = null)
{
$uuid = null;
/* Create a new UUID based on provided data. */
switch ((int) $ver) {
case 1:
$uuid = Uuid::uuid1($node, $clockSeq);
break;
case 2:
// Version 2 is not supported
throw new \RuntimeException('UUID version 2 is unsupported.');
case 3:
$uuid = Uuid::uuid3($ns, $name);
break;
case 4:
$uuid = Uuid::uuid4();
break;
case 5:
$uuid = Uuid::uuid5($ns, $name);
break;
default:
throw new \RuntimeException('Selected UUID version is invalid or unsupported.');
}
if (function_exists('gmp_strval')) {
return gmp_strval(gmp_init($uuid->getHex(), 16), 62);
}
return Base62::encode((string) $uuid->getInteger());
}
示例6: boot
/**
* Model boot method, sets guid on create.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->guid = Uuid::uuid1();
});
}
示例7: testNextReadBeyondEnd
/**
* @expectedException \OutOfBoundsException
*/
public function testNextReadBeyondEnd()
{
$event1 = new GenericDomainEventMessage(Uuid::uuid1(), 0, new \stdClass(), new MetaData());
$testSubject = new SimpleDomainEventStream(array($event1));
$testSubject->next();
$testSubject->next();
}
示例8: testResolveTarget_WithAnnotatedFields
public function testResolveTarget_WithAnnotatedFields()
{
$aggregateIdentifier = Uuid::uuid1();
$version = 1;
$actual = $this->testSubject->resolveTarget(GenericCommandMessage::asCommandMessage(new FieldAnnotatedCommand($aggregateIdentifier, $version)));
$this->assertEquals($aggregateIdentifier, $actual->getIdentifier());
$this->assertEquals($version, $actual->getVersion());
}
示例9: testRegisterCallbackInvokedWithAllRegisteredEvents
public function testRegisterCallbackInvokedWithAllRegisteredEvents()
{
$container = new EventContainer(Uuid::uuid1()->toString());
$container->addEvent(MetaData::emptyInstance(), new Event());
$this->assertFalse(current($container->getEventList())->getMetaData()->has("key"));
$container->addEventRegistrationCallback(new TestEventRegistrationCallback());
$this->assertEquals("value", current($container->getEventList())->getMetadata()->get("key"));
}
示例10: schedule
/**
* schedule.
*
* Schedule $command for later execution
* Returns a unique identifier for the scheduled execution
* If an $id was passed it'll overwrite the scheduled execution
*
* @since 1.0
*
* @param ScheduledCommandInterface $command
* @param string $id - optional
*
* @return string
*/
public function schedule(ScheduledCommandInterface $command, $id = null)
{
$fileName = isset($id) ? $id : Uuid::uuid1()->toString();
file_put_contents($this->path . DIRECTORY_SEPARATOR . $fileName, serialize($command));
$this->register[$fileName] = $command->getTimestamp();
file_put_contents($this->path . DIRECTORY_SEPARATOR . 'register', serialize($this->register));
return $fileName;
}
示例11: createVoucher
/**
* createVoucher function.
*
* @access public
*
* @param string $campaignUrn
*
* @return Voucher
*/
public function createVoucher($campaignUrn)
{
// Check for valid campaign
if ($campaign = $this->campaignRepo->loadCampaign($campaignUrn)) {
$voucher = $this->model->create(['campaign_id' => $campaign->id, 'hash' => Uuid::uuid1()->toString()]);
return $voucher;
}
return false;
}
示例12: __construct
/**
* @param mixed $payload
* @param MetaData $metadata
* @param string $id
*/
public function __construct($payload, MetaData $metadata = null, $id = null)
{
if (!is_object($payload)) {
throw new \InvalidArgumentException("Payload needs to be an object.");
}
$this->id = isset($id) ? $id : Uuid::uuid1()->toString();
$this->metadata = isset($metadata) ? $metadata : MetaData::emptyInstance();
$this->payload = $payload;
}
示例13: set
/**
* Set object with Auto document_id
* @param mixed $object Receive object to store
* @return string Return string with $document_id
*/
public function set($object, $document_id = null)
{
if (is_null($document_id) || !Uuid::isValid($document_id)) {
$document_id = strtoupper(Uuid::uuid1());
}
$this->resolvePath($this->dataPath);
file_put_contents($this->dataPath . DIRECTORY_SEPARATOR . $document_id, json_encode($object, JSON_PRETTY_PRINT), LOCK_EX);
return $document_id;
}
示例14: v1
/**
* UUID1,基于时间戳
*
* @param int|string $node
* @param int $clockSeq
* @return string
*/
public static function v1($node = null, $clockSeq = null)
{
try {
$uuid1 = VendorUUID::uuid1($node, $clockSeq);
return $uuid1->toString();
} catch (UnsatisfiedDependencyException $e) {
return false;
}
}
示例15: testCommandReply
public function testCommandReply()
{
$commandId1 = Uuid::uuid1()->toString();
$commandId2 = Uuid::uuid1()->toString();
$this->testSubject->writeCommandReply($commandId1, $commandId1);
$data = $this->testSubject->readCommandReply($commandId1);
$this->assertEquals($commandId1, $data[1]);
$data = $this->testSubject->readCommandReply($commandId2, 1);
$this->assertNull($data);
}