当前位置: 首页>>代码示例>>PHP>>正文


PHP Uuid::uuid4方法代码示例

本文整理汇总了PHP中Ramsey\Uuid\Uuid::uuid4方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::uuid4方法的具体用法?PHP Uuid::uuid4怎么用?PHP Uuid::uuid4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ramsey\Uuid\Uuid的用法示例。


在下文中一共展示了Uuid::uuid4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: book_in_reservation_can_be_given_away

 /** @test */
 public function book_in_reservation_can_be_given_away()
 {
     $reservation = new Reservation(Uuid::uuid4(), Uuid::uuid4(), 'employee@clearcode.cc');
     $reservation->giveAway(new \DateTime('2016-01-01 00:00:00'));
     $this->assertTrue($reservation->isGivenAway());
     $this->assertEquals((new \DateTime('2016-01-01 00:00:00'))->format('Y-m-d H:i:s'), $reservation->givenAwayAt()->format('Y-m-d H:i:s'));
 }
开发者ID:ClearcodeHQ,项目名称:eh-library,代码行数:8,代码来源:ReservationTest.php

示例2: __construct

 /**
  * Initializes a new instance of this class.
  *
  * @param string $name
  * @param string $homepage
  */
 public function __construct($name, $homepage)
 {
     $this->clientId = Uuid::uuid4();
     $this->createdOn = new DateTimeImmutable('now');
     $this->name = $name;
     $this->homepage = $homepage;
 }
开发者ID:zource,项目名称:zource,代码行数:13,代码来源:OAuthApplication.php

示例3: __construct

 public function __construct(array $params = null)
 {
     //All child class need to have constant UUID_CLASS_PREFIX to create uuid prefix
     if (!defined(get_class($this) . '::UUID_CLASS_PREFIX')) {
         throw new \Exception("Class " . get_class($this) . " has missing UUID_CLASS_PREFIX constant.");
     }
     //bind array values to class properties
     if ($params) {
         foreach ($params as $key => $value) {
             if (property_exists($this, $key)) {
                 $this->{$key} = $value;
             }
         }
     }
     //Add uuid if not exists for new created object
     if (property_exists($this, 'uuid')) {
         if (!$this->uuid) {
             $uuid = Uuid::uuid4()->toString();
             //Add uuid prefix (defined in UUID_CLASS_PREFIX constant) by replacing first x characters. Where x is prefix length.
             $prefix_length = strlen($this::UUID_CLASS_PREFIX);
             $uuid = substr_replace($uuid, $this::UUID_CLASS_PREFIX, 0, $prefix_length);
             $this->uuid = $uuid;
         }
     }
 }
开发者ID:marcyniu,项目名称:ai,代码行数:25,代码来源:Dto.php

示例4: send

 public function send()
 {
     if (!$this->validate()) {
         throw new SMSMessageException('Could not send message');
     }
     if (empty($this->strId)) {
         $objUuid = Uuid::uuid4();
         $this->strId = $objUuid->toString();
     }
     $arrParams = ['cc' => $this->strUsername, 'ekey' => $this->strPassword, 'message' => $this->strBody, 'title' => $this->strSenderId, 'network' => $this->strNetwork, 'value' => $this->fltValue, 'currency' => $this->strCurrency, 'encoding' => $this->strEncoding, 'number' => $this->strMsisdn, 'id' => $this->strId, 'reply' => $this->intReply];
     if ($this->blBinary) {
         $arrParams['binary'] = (int) $this->blBinary;
         $arrParams['udh'] = $this->strUdh;
     }
     if (!empty($this->shortcode)) {
         $arrParams['shortcode'] = $this->shortcode;
     }
     $this->objLogger->addDebug('Sending the following to txtNation:', $arrParams);
     $objClient = new Client(['base_uri' => 'http://client.txtnation.com/', 'timeout' => 10.0]);
     $objResponse = $objClient->get('/gateway.php', [RequestOptions::QUERY => $arrParams, RequestOptions::SYNCHRONOUS => true, RequestOptions::ALLOW_REDIRECTS => true, RequestOptions::HEADERS => ['User-agent' => 'txtNationGatewayLibraryPHP/1.0'], RequestOptions::HTTP_ERRORS => false]);
     $objResult = new SMSMessageResult($objResponse);
     $objResult->setCallbackId($this->strId);
     if (!$objResult->success()) {
         $this->objLogger->addAlert('Message was not sent. ', ['error' => $objResult->getErrorMessage()]);
     }
     return $objResult;
 }
开发者ID:saleemepoch,项目名称:txtnation,代码行数:27,代码来源:Request.php

示例5: boot

 /**
  * Boot the Uuid trait for the model.
  */
 protected static function boot()
 {
     static::creating(function ($model) {
         $model->incrementing = false;
         $model->{$model->getKeyName()} = Uuid::uuid4()->toString();
     });
 }
开发者ID:iolson,项目名称:support,代码行数:10,代码来源:UuidTrait.php

示例6: __construct

 public function __construct(array $state = [])
 {
     $this->metadata = [];
     $this->uuid = Uuid::uuid4()->toString();
     parent::__construct($state);
     $this->guardRequiredState();
 }
开发者ID:honeybee,项目名称:honeybee,代码行数:7,代码来源:Command.php

示例7: register

 /**
  * Register new email change
  * 
  * @param  string $userId
  * @param  string $email
  * @return void
  */
 public function register($userId, $email)
 {
     $emailReset = $this->model->firstOrNew(['user_id' => $userId]);
     $emailReset->email = $email;
     $emailReset->token = Uuid::uuid4();
     $emailReset->save();
 }
开发者ID:inoplate,项目名称:account,代码行数:14,代码来源:EloquentEmailReset.php

示例8: run

 public function run($type, callable $runCallback)
 {
     static $wrapperPassingRunCallback;
     if (!isset($wrapperPassingRunCallback)) {
         $wrapperPassingRunCallback = [];
     }
     if (is_null($this->consumerTag)) {
         $runCallbackWrapper = function (AMQPMessage $amqpMessage) use(&$wrapperPassingRunCallback) {
             $inputMessage = new InputMessage($amqpMessage->body);
             $runCallback = $wrapperPassingRunCallback['runCallback'];
             /** @var OutputMessage $outputMessage */
             $outputMessage = $runCallback($inputMessage);
             $channel = $amqpMessage->delivery_info['channel'];
             if ($amqpMessage->has('reply_to')) {
                 $replyQueueName = $amqpMessage->get('reply_to');
                 $id = $amqpMessage->get('correlation_id');
                 $replyAmqpMessage = new AMQPMessage($outputMessage->getData(), ['correlation_id' => $id]);
                 $channel->basic_publish($replyAmqpMessage, '', $replyQueueName);
             }
             $channel->basic_ack($amqpMessage->delivery_info['delivery_tag']);
         };
         $this->consumerTag = 'consumer_' . substr(Uuid::uuid4()->toString(), 0, 8);
         $this->channel->basic_qos(null, 1, null);
         $this->channel->basic_consume($this->getQueueName($type), $this->consumerTag, false, false, false, false, $runCallbackWrapper);
     }
     $wrapperPassingRunCallback['runCallback'] = $runCallback;
     $this->channel->wait();
     unset($wrapperPassingRunCallback['runCallback']);
 }
开发者ID:parallel-php,项目名称:parallel-task,代码行数:29,代码来源:RabbitMQQueue.php

示例9: create

 /**
  * {@inheritdoc}
  */
 public function create($user, array $data)
 {
     $creator = array_get($data, 'from');
     $notification = Notification::create(['id' => Uuid::uuid4(), 'user_id' => $user->id, 'created_by' => $creator ? $creator->id : null, 'icon' => $data['icon'], 'body' => $data['body'], 'action_text' => array_get($data, 'action_text'), 'action_url' => array_get($data, 'action_url')]);
     event(new NotificationCreated($notification));
     return $notification;
 }
开发者ID:defenestrator,项目名称:groid,代码行数:10,代码来源:NotificationRepository.php

示例10: generateUUID

 /**
  * Generates a universally unique identifier (UUID) according to RFC 4122.
  * The algorithm used here, might not be completely random.
  *
  * If php-uuid was installed it will be used instead to speed up the process.
  *
  * @return string The universally unique id
  * @todo Optionally generate type 1 and type 5 UUIDs.
  */
 public static function generateUUID()
 {
     if (is_callable('uuid_create')) {
         return strtolower(uuid_create(UUID_TYPE_RANDOM));
     }
     return (string) Uuid::uuid4();
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:16,代码来源:Algorithms.php

示例11: __construct

 /**
  * Initializes a new instance of this class.
  *
  * @param AccountInterface $account
  * @param string $name
  * @param string|null $value
  */
 public function __construct(AccountInterface $account, $name, $value)
 {
     $this->id = Uuid::uuid4();
     $this->account = $account;
     $this->name = $name;
     $this->value = $value;
 }
开发者ID:zource,项目名称:zource,代码行数:14,代码来源:Property.php

示例12: let

 public function let(ConfigTypeInterface $type)
 {
     $this->uuid = Uuid::uuid4();
     $this->type = $type;
     $this->beConstructedWith($this->uuid, $type, $this->name);
     $type->getDefaultItems()->willReturn($this->items);
 }
开发者ID:jschreuder,项目名称:SpotCms,代码行数:7,代码来源:ConfigCollectionSpec.php

示例13: it_generates_valid_uuid_with_both_namespaces

 /**
  * @test
  */
 public function it_generates_valid_uuid_with_both_namespaces()
 {
     $uuid1 = \Rhumsaa\Uuid\Uuid::uuid4();
     $uuid2 = \Ramsey\Uuid\Uuid::uuid4();
     $this->assertRegExp(self::UUID_REGEX, $uuid1->toString());
     $this->assertRegExp(self::UUID_REGEX, $uuid2->toString());
 }
开发者ID:MattKetmo,项目名称:uuid-2x-bridge,代码行数:10,代码来源:UuidTest.php

示例14: boot

 public static function boot()
 {
     parent::boot();
     // assign a guid for each model
     static::creating(function ($tournamentQuizmaster) {
         $tournamentQuizmaster->guid = Uuid::uuid4();
         return true;
     });
     // Make sure the user has the quizmaster role
     // Using a saved event since the user could be assigned
     // after the initial creation
     static::saved(function ($tournamentQuizmaster) {
         $user = $tournamentQuizmaster->user;
         // if no user is linked, try to find one
         if (is_null($user)) {
             $user = User::where('email', $tournamentQuizmaster->email)->first();
         }
         if (!is_null($user)) {
             // label the user as a quizmaster
             if ($user->isNotA(Role::QUIZMASTER)) {
                 $role = Role::where('name', Role::QUIZMASTER)->firstOrFail();
                 $user->assign($role);
             }
             // associate the user with the quizmaster
             if ($tournamentQuizmaster->user_id == null) {
                 $tournamentQuizmaster->update(['user_id' => $user->id]);
             }
         }
     });
 }
开发者ID:BibleBowl,项目名称:account,代码行数:30,代码来源:TournamentQuizmaster.php

示例15: uuid4

 public static function uuid4()
 {
     if (self::$isThrowing) {
         throw new UnsatisfiedDependencyException('TEST');
     }
     return Uuid::uuid4();
 }
开发者ID:steve-rodrigue,项目名称:ids,代码行数:7,代码来源:UuidClass.php


注:本文中的Ramsey\Uuid\Uuid::uuid4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。