本文整理汇总了PHP中Rhumsaa\Uuid\Uuid类的典型用法代码示例。如果您正苦于以下问题:PHP Uuid类的具体用法?PHP Uuid怎么用?PHP Uuid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Uuid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
/**
* @param Uuid $id
*/
public function find(Uuid $id)
{
$teamMember = $this->database->getRecord('SELECT *
FROM team_members
WHERE id = :id', ['id' => $id->getBytes()]);
if (empty($teamMember)) {
throw new \Exception('No teammember with id ' . $id->toString() . 'found');
}
return TeamMember::fromArray($teamMember);
}
示例2: createMessageFromArray
/**
* @param string $messageName
* @param array $messageData
* @throws \UnexpectedValueException
* @return DomainMessage
*/
public function createMessageFromArray($messageName, array $messageData)
{
if (!class_exists($messageName)) {
throw new \UnexpectedValueException('Given message name is not a valid class: ' . (string) $messageName);
}
$ref = new \ReflectionClass($messageName);
if (!$ref->isSubclassOf(DomainMessage::class)) {
throw new \UnexpectedValueException(sprintf('Message class %s is not a sub class of %s', $messageName, DomainMessage::class));
}
if (!isset($messageData['message_name'])) {
$messageData['message_name'] = $messageName;
}
if (!isset($messageData['uuid'])) {
$messageData['uuid'] = Uuid::uuid4();
}
if (!isset($messageData['version'])) {
$messageData['version'] = 1;
}
if (!isset($messageData['created_at'])) {
$messageData['created_at'] = new \DateTimeImmutable();
}
if (!isset($messageData['metadata'])) {
$messageData['metadata'] = [];
}
return $messageName::fromArray($messageData);
}
示例3: testSameValueAs
public function testSameValueAs()
{
$sameMetaInformation = new MetaInformation($this->metaInformation->workflowRunId(), $this->metaInformation->actionId(), new Name('TestQuery'), new Arguments(array('foo' => 'bar')), 5);
$otherMetaInformation = new MetaInformation(new WorkflowRunId(Uuid::uuid4()), new ActionId(Uuid::uuid4()), new Name('AnotherOuery'), new Arguments(array('foo' => 'bar')), 10);
$this->assertTrue($this->metaInformation->sameValueAs($sameMetaInformation));
$this->assertFalse($this->metaInformation->sameValueAs($otherMetaInformation));
}
示例4: create
public function create($title, $author, $isbn)
{
$bookId = (string) Uuid::uuid4();
$book = array('book_id' => $bookId, 'title' => $title, 'author' => $author, 'isbn' => $isbn);
$this->books->insert($book);
return new $this->entityClass($book);
}
示例5: create
public function create($attributes)
{
if (!isset($attributes['txid']) and !isset($attributes['request_id'])) {
throw new Exception("TXID or request ID is required", 1);
}
if (!isset($attributes['payment_address_id'])) {
throw new Exception("payment_address_id is required", 1);
}
if (!isset($attributes['user_id'])) {
throw new Exception("user_id is required", 1);
}
if (!isset($attributes['destination']) and !isset($attributes['destinations'])) {
throw new Exception("destination is required", 1);
}
if (!isset($attributes['quantity_sat'])) {
throw new Exception("quantity_sat is required", 1);
}
if (!isset($attributes['asset'])) {
throw new Exception("asset is required", 1);
}
if (!isset($attributes['uuid'])) {
$attributes['uuid'] = Uuid::uuid4()->toString();
}
return Send::create($attributes);
}
示例6: setUp
public function setUp()
{
$this->userId = new UserId(Uuid::uuid4());
$this->email = new Email('name@domain.com');
$this->username = new Username('my_username');
$this->password = new HashedPassword('super_secret_password');
}
示例7: __construct
public function __construct($name, Email $email, HashedPassword $password)
{
$this->setId(Uuid::uuid4());
$this->setUserName($name);
$this->setEmail($email);
$this->setPassword($password);
}
示例8: 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);
}
}
示例9: generateUniqueId
/**
* {@inheritDoc}
*/
public function generateUniqueId($name = null)
{
if (empty($name)) {
$name = uniqid($name, $moreEnthropy = true);
}
return RhumsaaUuid::uuid5(RhumsaaUuid::NAMESPACE_OID, $name)->toString();
}
示例10: testParseWithUuidTagHandler
function testParseWithUuidTagHandler()
{
$expected = [Uuid::fromString('f81d4fae-7dec-11d0-a765-00a0c91e6bf6')];
$edn = '#uuid "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"';
$data = igorw\edn\parse($edn);
$this->assertEquals($expected, $data);
}
示例11: rootAction
public function rootAction(Application $app, Request $request)
{
$data = $this->prepareInput();
if ($data === null) {
return new JsonResponse(['error' => 'no json data found'], 400);
}
$templateName = isset($data['template']) ? $data['template'] : null;
$templateData = isset($data['data']) ? $data['data'] : null;
if (!$templateName || !$templateData) {
return new JsonResponse(['error' => 'template and data must be set'], 400);
}
$repo = $app->getTemplateRepository();
$template = $repo->getByName($templateName);
if (!$template) {
return new JsonResponse(['error' => "template {$templateName} not found"], 404);
}
$twig = new \Twig_Environment(new \Twig_Loader_String());
$html = $twig->render($template->getTemplate(), $templateData);
$file = new File();
$file->setId(Uuid::uuid4()->toString());
$file->setCreatedAt(date('Y-m-d H:i:s'));
$file->setPath($this->getFilePath($file));
$snappy = new Pdf();
if (substr(php_uname(), 0, 7) == "Windows") {
$snappy->setBinary('vendor\\bin\\wkhtmltopdf.exe.bat');
} else {
$snappy->setBinary('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');
}
$snappy->generateFromHtml($html, $file->getPath());
$repo = $app->getFileRepository();
$repo->add($file);
return new JsonResponse(['id' => $file->getId()], 201);
}
示例12: 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());
}
示例13: testUuidToBinary
public function testUuidToBinary()
{
$uuid = Uuid::uuid5(Uuid::NAMESPACE_OID, 1);
$binary = UuidConverter::uuidToBinary($uuid->toString());
$finalUuid = Uuid::fromBytes($binary);
$this->assertSame($uuid->toString(), $finalUuid->toString());
}
示例14: setUpBeforeClass
/**
* @inheritdoc
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
foreach (self::$uuids as $i => $uuid) {
self::$uuids[$i] = Uuid::fromString($uuid);
}
}
示例15: generateNewKey
public function generateNewKey()
{
$apikey = new ApiKey();
$apikey->key = Uuid::uuid4()->toString();
$apikey->save();
return $apikey;
}