当前位置: 首页>>代码示例>>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;未经允许,请勿转载。