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