當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uuid\Uuid類代碼示例

本文整理匯總了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);
 }
開發者ID:WouterSioen,項目名稱:fork-cms-module-team,代碼行數:13,代碼來源:TeamMemberRepository.php

示例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);
 }
開發者ID:prolic,項目名稱:common,代碼行數:32,代碼來源:FQCNMessageFactory.php

示例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));
 }
開發者ID:gingerwfms,項目名稱:ginger-workflow-engine,代碼行數:7,代碼來源:MetaInformationTest.php

示例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);
 }
開發者ID:alapini,項目名稱:apigility-3hr-tutorial,代碼行數:7,代碼來源:BookMapper.php

示例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);
 }
開發者ID:CryptArc,項目名稱:xchain,代碼行數:25,代碼來源:SendRepository.php

示例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');
 }
開發者ID:snb4crazy,項目名稱:cribbb,代碼行數:7,代碼來源:UserTest.php

示例7: __construct

 public function __construct($name, Email $email, HashedPassword $password)
 {
     $this->setId(Uuid::uuid4());
     $this->setUserName($name);
     $this->setEmail($email);
     $this->setPassword($password);
 }
開發者ID:RCAbney,項目名稱:L5-Doctrine-Base,代碼行數:7,代碼來源:User.php

示例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);
     }
 }
開發者ID:Charu91,項目名稱:Wowtables1,代碼行數:34,代碼來源:UserController.php

示例9: generateUniqueId

 /**
  * {@inheritDoc}
  */
 public function generateUniqueId($name = null)
 {
     if (empty($name)) {
         $name = uniqid($name, $moreEnthropy = true);
     }
     return RhumsaaUuid::uuid5(RhumsaaUuid::NAMESPACE_OID, $name)->toString();
 }
開發者ID:absolvent,項目名稱:php-guid,代碼行數:10,代碼來源:Uuid.php

示例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);
 }
開發者ID:igorw,項目名稱:edn,代碼行數:7,代碼來源:ParserTest.php

示例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);
 }
開發者ID:v03adk,項目名稱:pdf-generation-server,代碼行數:33,代碼來源:ApiController.php

示例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());
 }
開發者ID:gponster,項目名稱:laravel-url62-uuid,代碼行數:28,代碼來源:Url62UuidGenerator.php

示例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());
 }
開發者ID:ellipsesynergie,項目名稱:backend-skeleton,代碼行數:7,代碼來源:UuidConverterTest.php

示例14: setUpBeforeClass

 /**
  * @inheritdoc
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     foreach (self::$uuids as $i => $uuid) {
         self::$uuids[$i] = Uuid::fromString($uuid);
     }
 }
開發者ID:a-mayer,項目名稱:boekkooi-broadway,代碼行數:10,代碼來源:MockUuidSequenceGeneratorTest.php

示例15: generateNewKey

 public function generateNewKey()
 {
     $apikey = new ApiKey();
     $apikey->key = Uuid::uuid4()->toString();
     $apikey->save();
     return $apikey;
 }
開發者ID:clubttt,項目名稱:SuccessModel4,代碼行數:7,代碼來源:ApiKeyService.php


注:本文中的Rhumsaa\Uuid\Uuid類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。