php Rhumsaa-Uuid-Uuid类(方法)实例源码

下面列出了php Rhumsaa-Uuid-Uuid 类(方法)源码代码实例,从而了解它的用法。

作者:WouterSioe    项目:fork-cms-module-tea   
/**
  * @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);
 }

作者:proli    项目:commo   
/**
  * @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);
 }

作者:gingerwfm    项目:ginger-workflow-engin   
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));
 }

作者:alapin    项目:apigility-3hr-tutoria   
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);
 }

作者:CryptAr    项目:xchai   
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);
 }

作者:snb4craz    项目:cribb   
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');
 }

作者:RCAbne    项目:L5-Doctrine-Bas   
public function __construct($name, Email $email, HashedPassword $password)
 {
     $this->setId(Uuid::uuid4());
     $this->setUserName($name);
     $this->setEmail($email);
     $this->setPassword($password);
 }

作者:Charu9    项目:Wowtables   
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);
     }
 }

作者:absolven    项目:php-gui   
/**
  * {@inheritDoc}
  */
 public function generateUniqueId($name = null)
 {
     if (empty($name)) {
         $name = uniqid($name, $moreEnthropy = true);
     }
     return RhumsaaUuid::uuid5(RhumsaaUuid::NAMESPACE_OID, $name)->toString();
 }

作者:igor    项目:ed   
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);
 }

作者:v03ad    项目:pdf-generation-serve   
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);
 }

作者:gponste    项目:laravel-url62-uui   
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());
 }

作者:ellipsesynergi    项目:backend-skeleto   
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());
 }

作者:a-maye    项目:boekkooi-broadwa   
/**
  * @inheritdoc
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     foreach (self::$uuids as $i => $uuid) {
         self::$uuids[$i] = Uuid::fromString($uuid);
     }
 }

作者:clubtt    项目:SuccessModel   
public function generateNewKey()
 {
     $apikey = new ApiKey();
     $apikey->key = Uuid::uuid4()->toString();
     $apikey->save();
     return $apikey;
 }

作者:xamin12    项目:platfor   
/**
  * Load items
  *
  * @param ObjectManager $manager
  */
 public function loadItems($manager)
 {
     for ($ind = 1; $ind <= self::COUNT; $ind++) {
         //create item
         /** @var $item Item */
         $item = new Item();
         //string value
         $item->stringValue = 'item' . $ind . '@mail.com';
         $item->integerValue = $ind * 1000;
         //decimal
         $item->decimalValue = $ind / 10.0;
         //float
         $item->floatValue = $ind / 10.0 + 10;
         //boolean
         $item->booleanValue = rand(0, 1) == true;
         //blob
         $item->blobValue = "blob-{$ind}";
         //array
         $item->arrayValue = array($ind);
         //datetime
         $date = new \DateTime('now', new \DateTimeZone('UTC'));
         $date->add(new \DateInterval("P{$ind}Y"));
         $item->datetimeValue = $date;
         //guid
         $item->guidValue = Uuid::uuid4();
         //object
         $item->objectValue = new \stdClass();
         $manager->persist($item);
     }
     $manager->flush();
 }

作者:gingerwfm    项目:ginger-workflow-engin   
protected function setUp()
 {
     $this->queryResultId = new QueryResultId(Uuid::uuid4());
     $this->metaInformation = new MetaInformation(new WorkflowRunId(Uuid::uuid4()), new ActionId(Uuid::uuid4()), new Name('TestQuery'), new Arguments(array('foo' => 'bar')), 1);
     $this->result = new Item('A result item');
     $this->queryResultCreated = new QueryResultCreated(array('queryResultId' => $this->queryResultId->toString(), 'metaInformation' => $this->metaInformation->toArray(), 'result' => array('resultClass' => get_class($this->result), 'data' => $this->result->toJSON())));
 }

作者:joemar-tagpun    项目:uui   
/**
  * @covers Rhumsaa\Uuid\Doctrine\UuidType::convertToDatabaseValue
  */
 public function testUuidConvertsToDatabaseValue()
 {
     $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
     $expected = $uuid->toString();
     $actual = $this->type->convertToDatabaseValue($uuid, $this->platform);
     $this->assertEquals($expected, $actual);
 }

作者:TeamAppEngin    项目:adraaf.serve   
public function store(Request $request)
 {
     //get the email and password from the input
     $email = "";
     $password = "";
     if ($request->get('email') && $request->get('password')) {
         $password = $request->get('password');
         if (Libraries\InputValidator::isEmailValid($request->get('email'))) {
             $email = $request->get('email');
         } else {
             \App::abort(400, 'The contract of the api was not met');
         }
     } else {
         \App::abort(400, 'The contract of the api was not met');
     }
     //get the user based on the email
     $userRepo = new UserRepository(new User());
     $user = $userRepo->getUserBasedOnEmail($email)->toArray();
     //fill the information of the user
     //if the user didn't exist
     $userInfo = [];
     if ($user == []) {
         $userInfo = ["email" => $email, "password" => sha1($password), "uuid" => \Rhumsaa\Uuid\Uuid::uuid4()->toString()];
     } else {
         \App::abort(409, 'The email is already in use');
     }
     //update the information of the user
     $user = $userRepo->updateUserInfo($userInfo);
     $userRepo->setUserLevel(1);
     $userRepo->logSignUp();
     //send the results back to the user
     return json_encode(["status" => ["points" => $userRepo->getUserPoints(), "level" => $userRepo->getUserLevel()->id], "user_id" => $user->uuid, "email" => $email, "password" => sha1($password)]);
 }

作者:borobudur-ph    项目:borobudur-cqr   
/**
  * {@inheritdoc}
  *
  * @return static
  */
 public static function fromString($id)
 {
     if (null === $id) {
         return null;
     }
     return new static(Uuid::fromString($id));
 }


问题


面经


文章

微信
公众号

扫码关注公众号