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


PHP Uuid::isValid方法代碼示例

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


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

示例1: isValid

 /**
  * @param string $guid
  * @return bool
  */
 public static function isValid($guid)
 {
     if (!Uuid::isValid($guid) || !preg_match('/' . self::UUID4_PATTERN . '/', $guid)) {
         return false;
     }
     return true;
 }
開發者ID:sil-student-projects,項目名稱:web-languageforge,代碼行數:11,代碼來源:Guid.php

示例2: __construct

 /**
  * @param string $value
  */
 public function __construct(string $value)
 {
     if (!\Ramsey\Uuid\Uuid::isValid($value)) {
         throw new \InvalidArgumentException(sprintf('%s is not a valid Uuid.', $value));
     }
     $this->value = \Ramsey\Uuid\Uuid::fromString($value);
 }
開發者ID:rayrutjes,項目名稱:php-geteventstore-client,代碼行數:10,代碼來源:Uuid.php

示例3: deserializeUuidValue

 /**
  * @param string $uuidString
  * @return \Ramsey\Uuid\UuidInterface
  */
 private function deserializeUuidValue($uuidString)
 {
     if (!Uuid::isValid($uuidString)) {
         throw new \Mhujer\JmsSerializer\Uuid\InvalidUuidException($uuidString);
     }
     return Uuid::fromString($uuidString);
 }
開發者ID:mhujer,項目名稱:jms-serializer-uuid,代碼行數:11,代碼來源:UuidSerializerHandler.php

示例4: testNewUuid

 /**
  * @covers Alchemy\Phrasea\Border\File::getUUID
  */
 public function testNewUuid()
 {
     $file = __DIR__ . '/../../../../files/temporay.jpg';
     if (file_exists($file)) {
         unlink($file);
     }
     copy(__DIR__ . '/../../../../files/p4logo.jpg', $file);
     $borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
     $uuid = $borderFile->getUUID(true, false);
     $this->assertTrue(Uuid::isValid($uuid));
     $this->assertEquals($uuid, $borderFile->getUUID());
     $borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
     $newuuid = $borderFile->getUUID(true, true);
     $this->assertTrue(Uuid::isValid($newuuid));
     $this->assertNotEquals($uuid, $newuuid);
     $this->assertEquals($newuuid, $borderFile->getUUID());
     $borderFile = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess($file), self::$DI['collection']);
     $uuid = $borderFile->getUUID();
     $this->assertTrue(Uuid::isValid($uuid));
     $this->assertEquals($uuid, $newuuid);
     $this->assertEquals($uuid, $borderFile->getUUID());
     if (file_exists($file)) {
         unlink($file);
     }
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:28,代碼來源:FileTest.php

示例5: __construct

 /**
  * @param string $entity_id
  */
 public function __construct($entity_id = null)
 {
     if (is_null($entity_id) || false === Uuid::isValid($entity_id)) {
         $entity_id = Uuid::uuid4();
     }
     $this->entity_id = $entity_id;
 }
開發者ID:HHPnet,項目名稱:core,代碼行數:10,代碼來源:EntityId.php

示例6: testGenerate

 public function testGenerate()
 {
     $id = UuidIdentifier::generate();
     $this->assertTrue(Uuid::isValid($id));
     $uuid = Uuid::fromString($id->toString());
     $this->assertTrue($uuid->getVersion() == 4);
 }
開發者ID:gdbots,項目名稱:pbj-php,代碼行數:7,代碼來源:UuidIdentifierTest.php

示例7: fromString

 public static function fromString(string $uuid)
 {
     if (!Uuid::isValid($uuid)) {
         throw new \InvalidArgumentException(sprintf('%s is not valid uuid', $uuid));
     }
     return new Id(Uuid::fromString($uuid)->toString());
 }
開發者ID:cocoders,項目名稱:event-store,代碼行數:7,代碼來源:Id.php

示例8: setUuidFromString

 /**
  * @param string $string
  *
  * @throws OrmException
  *
  * @return $this
  */
 public function setUuidFromString($string)
 {
     if (!Uuid::isValid($string)) {
         throw OrmException::create()->setMessage('Invalid Uuid string provided.');
     }
     $this->uuid = Uuid::fromString($string);
     return $this;
 }
開發者ID:scr-be,項目名稱:arthur-doctrine-entity-traits-library,代碼行數:15,代碼來源:UuidMutableTrait.php

示例9: getMatchers

 public function getMatchers()
 {
     return ['beValidUUID' => function ($uuid) {
         return Uuid::isValid($uuid);
     }, 'beEqualUUID' => function ($uuid, $value) {
         return Uuid::fromString($uuid)->equals(Uuid::fromString($uuid));
     }];
 }
開發者ID:HHPnet,項目名稱:core,代碼行數:8,代碼來源:EntityId.php

示例10: isValid

 /**
  * {@inheritDoc}
  */
 public function isValid($value)
 {
     if (!UuidImpl::isValid($value)) {
         $this->error(self::INVALID_UUID);
         return false;
     }
     $this->setValue($value);
     return true;
 }
開發者ID:zource,項目名稱:zource,代碼行數:12,代碼來源:Uuid.php

示例11: getAccessToken

 /**
  * {@inheritdoc}
  */
 public function getAccessToken($grant, array $options = [])
 {
     if (!isset($options['guid']) || !Uuid::isValid($options['guid'])) {
         throw new \RuntimeException(sprintf('%s requires a "guid" option with a valid v4 UUID.', __METHOD__));
     }
     // Temporarily fake an access token for Local provider.
     $defaultOptions = ['access_token' => Uuid::uuid4()->toString(), 'resource_owner_id' => $options['guid'], 'refresh_token' => Uuid::uuid4()->toString(), 'expires' => 86400];
     return new AccessToken(array_merge($defaultOptions, $options));
 }
開發者ID:bolt,項目名稱:Members,代碼行數:12,代碼來源:Local.php

示例12: convertToDatabaseValue

 /**
  * {@inheritdoc}
  *
  * @param mixed            $value
  * @param AbstractPlatform $platform
  *
  * @throws ConversionException
  *
  * @return null|string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return null;
     }
     if ($value instanceof Uuid || Uuid::isValid($value)) {
         return (string) $value;
     }
     throw OrmTypeConversionException::create()->with($value, self::NAME);
 }
開發者ID:scr-be,項目名稱:arthur-doctrine-uuid-library,代碼行數:20,代碼來源:StringUuidType.php

示例13: convertToDatabaseValue

 /**
  * {@inheritdoc}
  *
  * @param Uuid|null                                 $value
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return null;
     }
     if ($value instanceof Uuid || Uuid::isValid($value)) {
         return $value->getBytes();
     }
     throw ConversionException::conversionFailed($value, self::NAME);
 }
開發者ID:EdgarPE,項目名稱:uuid-doctrine,代碼行數:16,代碼來源:UuidBinaryType.php

示例14: convertToDatabaseValue

 /**
  * Converts a value from its PHP representation to its database representation of this type.
  *
  * @param mixed $value The value to convert.
  *
  * @return string
  */
 public function convertToDatabaseValue($value)
 {
     if (null === $value) {
         return null;
     }
     if ($value instanceof Uuid || Uuid::isValid($value)) {
         return (string) $value;
     }
     throw ConversionException::conversionFailed($value, self::NAME);
 }
開發者ID:johanderuijter,項目名稱:uuid-doctrine-odm,代碼行數:17,代碼來源:UuidType.php

示例15: execute

 /**
  * {@inheritDoc}
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!Uuid::isValid($input->getArgument('uuid'))) {
         throw new Exception('Invalid UUID (' . $input->getArgument('uuid') . ')');
     }
     $uuid = Uuid::fromString($input->getArgument('uuid'));
     $table = $this->createTable($output);
     $this->setTableLayout($table);
     (new UuidFormatter())->write($table, $uuid);
     $table->render($output);
 }
開發者ID:ramsey,項目名稱:uuid-console,代碼行數:17,代碼來源:DecodeCommand.php


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