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


PHP Uuid::uuid1方法代碼示例

本文整理匯總了PHP中Ramsey\Uuid\Uuid::uuid1方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uuid::uuid1方法的具體用法?PHP Uuid::uuid1怎麽用?PHP Uuid::uuid1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ramsey\Uuid\Uuid的用法示例。


在下文中一共展示了Uuid::uuid1方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Initialize the saga. If an identifier is provided it will be used, otherwise a random UUID will be generated.
  * 
  * @param string $identifier
  */
 public function __construct($identifier = null)
 {
     $this->identifier = null === $identifier ? Uuid::uuid1()->toString() : $identifier;
     $this->associationValues = new AssociationValuesImpl();
     $this->inspector = new SagaMethodMessageHandlerInspector($this);
     $this->associationValues->add(new AssociationValue('sagaIdentifier', $this->identifier));
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:12,代碼來源:AbstractAnnotatedSaga.php

示例2: getTaxList

 /**
  * 獲取稅務信息
  * @return mixed
  * @param Request $request
  * @author AndyLee <root@lostman.org>
  */
 public function getTaxList(Request $request)
 {
     $company = Company::find($request->session()->get('customer_id'));
     $start = new \DateTime($company->created_at);
     $end = new DateTime();
     $interval = DateInterval::createFromDateString('1 month');
     $period = new DatePeriod($start, $interval, $end);
     $card = [];
     foreach ($period as $dt) {
         $map = ['user_id' => $request->session()->get('company_id'), 'company_id' => $request->session()->get('customer_id'), 'flag' => $dt->format("Ym")];
         $tax = Tax::where($map)->first();
         if (empty($tax)) {
             $record = new Tax();
             $record->user_id = $request->session()->get('company_id');
             $record->company_id = $request->session()->get('customer_id');
             $record->operator_id = Auth::user()->id;
             $record->card_name = $dt->format("Ym") . '稅務申報單';
             $record->finish_time = strtotime($dt->format('Y-m') . '-15');
             $record->uuid = Uuid::uuid1();
             $record->guoshui_status = 0;
             $record->dishui_status = 0;
             $record->flag = $dt->format("Ym");
             $record->save();
             $card[] = $record->toArray();
         } else {
             $card[] = $tax->toArray();
         }
     }
     $card = array_reverse($card);
     return view('customer.tax.index')->with('cards', $card);
 }
開發者ID:n0th1n9,項目名稱:daizhang,代碼行數:37,代碼來源:TaxController.php

示例3: generateId

 /**
  * Generate ID
  * @return String
  */
 public function generateId($version = 4, $includeDash = false)
 {
     try {
         switch ($version) {
             case 1:
                 $uuid = Uuid::uuid1();
                 break;
             case 3:
                 $uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, php_uname('n'));
                 break;
             case 5:
                 $uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, php_uname('n'));
                 break;
             default:
                 $uuid = Uuid::uuid4();
                 break;
         }
         return $includeDash ? $uuid->toString() : str_replace('-', '', $uuid->toString());
     } catch (UnsatisfiedDependencyException $e) {
         // Some dependency was not met. Either the method cannot be called on a
         // 32-bit system, or it can, but it relies on Moontoast\Math to be present.
         echo 'Caught exception: ' . $e->getMessage() . "\n";
         exit;
     }
 }
開發者ID:transformatika,項目名稱:utility,代碼行數:29,代碼來源:Str.php

示例4: handlePost

function handlePost($app, $request)
{
    // Timestamp & reverse-timestamp
    $odt = new DateTime('now', new DateTimeZone("Europe/Amsterdam"));
    $timestamp = $odt->format("Y-m-d H:i");
    $rtimestamp = $odt->format("siHdmY");
    try {
        $uuid1 = Uuid::uuid1();
        // Make sure the media file was uploaded without error
        $file = $request->files->get('mediaFile');
        if (!$file instanceof UploadedFile || $file->getError()) {
            throw new \InvalidArgumentException('The file is not valid.');
        }
        $ofilename = $rtimestamp . '-' . $file->getFilename();
        // create a thumbnail
        $image = $app['imagine']->open($file->getPathname());
        $tfilename = $rtimestamp . '-' . $file->getFilename() . '-thumb.jpeg';
        $tfilepath = $file->getPath() . '/' . $tfilename;
        $image->resize(new Box(200, 200))->save($tfilepath);
        // Upload the original media file to S3
        $ores = $app['aws.s3']->upload($app['env.orig'], $ofilename, fopen($file->getPathname(), 'r'), 'public-read');
        // upload the thumbnail
        $tres = $app['aws.s3']->upload($app['env.trans'], $tfilename, fopen($tfilepath, 'r'), 'public-read');
        // add file metadata
        $dynamoDbResult = $app['aws.ddb']->putItem(['TableName' => $app['env.table'], 'Item' => ['owner' => ['S' => 'PHP-User'], 'uid' => ['S' => $uuid1->toString()], 'timestamp' => ['S' => $timestamp], 'description' => ['S' => (string) $request->request->get('caption')], 'name' => ['S' => $file->getClientOriginalName()], 'source' => ['S' => $ofilename], 'thumbnail' => ['S' => $tfilename]]]);
        return array('type' => 'success', 'message' => 'File uploaded.');
    } catch (Exception $e) {
        // @TODO if something fails, rollback any object uploads
        return array('type' => 'error', 'message' => "Error uploading your photo:" . $e);
    }
}
開發者ID:AWSLuxGroup,項目名稱:workshop1-php,代碼行數:31,代碼來源:app.php

示例5: testNextReadBeyondEnd

 /**
  * @expectedException \OutOfBoundsException
  */
 public function testNextReadBeyondEnd()
 {
     $event1 = new GenericDomainEventMessage(Uuid::uuid1(), 0, new \stdClass(), new MetaData());
     $testSubject = new SimpleDomainEventStream(array($event1));
     $testSubject->next();
     $testSubject->next();
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:10,代碼來源:SimpleDomainEventStreamTest.php

示例6: performTransaction

 /**
  * Performs a new transaction.
  *
  * @param Cielo $cielo
  *
  * @return stdClass
  */
 public function performTransaction(Cielo $cielo)
 {
     $headers = ['MerchantId' => $cielo->getMerchantId(), 'MerchantKey' => $cielo->getMerchantKey(), 'RequestId' => $this->requestId];
     $json = ['MerchantOrderId' => Uuid::uuid1(), 'Customer' => $cielo->getCustomer()->toArray(), 'Payment' => $cielo->getPaymentMethod()->toArray()];
     $res = $this->perform->post('/1/sales', compact('headers', 'json'));
     return json_decode($res->getBody()->getContents());
 }
開發者ID:ianrodriguesbr,項目名稱:cielo-api,代碼行數:14,代碼來源:CieloClient.php

示例7: createUuid

 /**
  * Creates the requested UUID
  *
  * @param int $version
  * @param string $namespace
  * @param string $name
  * @return Uuid
  */
 protected function createUuid($version, $namespace = null, $name = null)
 {
     switch ((int) $version) {
         case 1:
             $uuid = Uuid::uuid1();
             break;
         case 4:
             $uuid = Uuid::uuid4();
             break;
         case 3:
         case 5:
             $ns = $this->validateNamespace($namespace);
             if (empty($name)) {
                 throw new Exception('The name argument is required for version 3 or 5 UUIDs');
             }
             if ($version == 3) {
                 $uuid = Uuid::uuid3($ns, $name);
             } else {
                 $uuid = Uuid::uuid5($ns, $name);
             }
             break;
         default:
             throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
     }
     return $uuid;
 }
開發者ID:ramsey,項目名稱:uuid-console,代碼行數:34,代碼來源:GenerateCommand.php

示例8: bootUuidForKey

 /**
  * Boot the Uuid trait for the model.
  *
  * @return void
  */
 public static function bootUuidForKey()
 {
     static::creating(function ($model) {
         $model->incrementing = false;
         $model->{$model->getKeyName()} = (string) Uuid::uuid1();
     });
 }
開發者ID:jysnkun05,項目名稱:SEDPI-WebApp,代碼行數:12,代碼來源:UuidForKey.php

示例9: __construct

 /**
  * @param mixed $payload
  * @param MetaData $metaData
  * @param string|null $id
  * @param string|null $commandName
  */
 public function __construct($payload, MetaData $metaData = null, $id = null, $commandName = null)
 {
     $this->id = null === $id ? Uuid::uuid1()->toString() : $id;
     $this->commandName = null === $commandName ? get_class($payload) : $commandName;
     $this->payload = $payload;
     $this->metaData = null === $metaData ? MetaData::emptyInstance() : $metaData;
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:13,代碼來源:GenericCommandMessage.php

示例10: onCreateArchive

 /**
  * @param ExportEventInterface $event
  * @throws CloseArchiveException
  * @throws OpenArchiveException
  * @throws UnavailableArchiveException
  */
 public function onCreateArchive(ExportEventInterface $event)
 {
     $archiveName = (string) Uuid::uuid1();
     $projectRootDir = realpath($this->projectRootDir);
     $archivePath = realpath($this->archiveDir) . '/' . $archiveName . '.zip';
     $archive = $this->openArchive($archivePath);
     foreach ($this->exportedCollection as $exportable) {
         if ($exportable instanceof ExportableInterface) {
             $exportPath = $projectRootDir . '/' . $exportable->getExportDestination();
             if (file_exists($exportPath)) {
                 $exportFile = new \SplFileObject($exportPath);
                 $archive->addFile($exportPath, $exportFile->getFilename());
             } else {
                 $this->logger->error(sprintf('Could not find export at "%s"', $exportPath));
                 // TODO Emit ErrorEvent to be handled later on for more robustness
                 continue;
             }
         }
     }
     $this->closeArchive($archive, $archivePath);
     if ($event instanceof JobAwareEventInterface) {
         if (!file_exists($archivePath)) {
             throw new UnavailableArchiveException(sprintf('Could not find archive at "%s"', $archivePath), UnavailableArchiveException::DEFAULT_CODE);
         }
         /** @var \WeavingTheWeb\Bundle\ApiBundle\Entity\Job $job */
         $job = $event->getJob();
         $archiveFile = new \SplFileObject($archivePath);
         $filename = str_replace('.zip', '', $archiveFile->getFilename());
         $router = $this->router;
         $getArchiveUrl = $this->router->generate('weaving_the_web_api_get_archive', ['filename' => $filename], $router::ABSOLUTE_PATH);
         $job->setOutput($getArchiveUrl);
     }
     $this->exportedCollection = [];
 }
開發者ID:WeavingTheWeb,項目名稱:devobs,代碼行數:40,代碼來源:ExportSubscriber.php

示例11: generateTransactionRef

 /**
  * generates a unique transaction ref used for init-ing transactions.
  *
  * @return mixed|null
  */
 public static function generateTransactionRef()
 {
     try {
         return str_replace('-', '', Uuid::uuid1()->toString());
     } catch (UnsatisfiedDependencyException $e) {
         return null;
     }
 }
開發者ID:MalikAbiola,項目名稱:paystack-php-lib,代碼行數:13,代碼來源:Utils.php

示例12: testRegisterCallbackInvokedWithAllRegisteredEvents

 public function testRegisterCallbackInvokedWithAllRegisteredEvents()
 {
     $container = new EventContainer(Uuid::uuid1()->toString());
     $container->addEvent(MetaData::emptyInstance(), new Event());
     $this->assertFalse(current($container->getEventList())->getMetaData()->has("key"));
     $container->addEventRegistrationCallback(new TestEventRegistrationCallback());
     $this->assertEquals("value", current($container->getEventList())->getMetadata()->get("key"));
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:8,代碼來源:EventContainerTest.php

示例13: testResolveTarget_WithAnnotatedFields

 public function testResolveTarget_WithAnnotatedFields()
 {
     $aggregateIdentifier = Uuid::uuid1();
     $version = 1;
     $actual = $this->testSubject->resolveTarget(GenericCommandMessage::asCommandMessage(new FieldAnnotatedCommand($aggregateIdentifier, $version)));
     $this->assertEquals($aggregateIdentifier, $actual->getIdentifier());
     $this->assertEquals($version, $actual->getVersion());
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:8,代碼來源:AnnotationCommandTargetResolverTest.php

示例14: setUuid

 /**
  * @param null|string $uuid
  *
  * @return $this
  */
 public function setUuid($uuid = null)
 {
     try {
         $this->uuid = $uuid instanceof Uuid ? $uuid : Uuid::fromString($uuid);
     } catch (\InvalidArgumentException $e) {
         $this->uuid = Uuid::uuid1();
     }
     return $this;
 }
開發者ID:src-run,項目名稱:arthur-doctrine-identity-library,代碼行數:14,代碼來源:UuidEntity.php

示例15: __construct

 /**
  * @param mixed $payload
  * @param MetaData $metadata
  * @param string $id
  */
 public function __construct($payload, MetaData $metadata = null, $id = null)
 {
     if (!is_object($payload)) {
         throw new \InvalidArgumentException("Payload needs to be an object.");
     }
     $this->id = isset($id) ? $id : Uuid::uuid1()->toString();
     $this->metadata = isset($metadata) ? $metadata : MetaData::emptyInstance();
     $this->payload = $payload;
 }
開發者ID:fcm,項目名稱:GovernorFramework,代碼行數:14,代碼來源:GenericMessage.php


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