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


PHP Uuid::fromString方法代码示例

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


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

示例1: testUuidConvertsToDatabaseValue

 public function testUuidConvertsToDatabaseValue()
 {
     $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
     $expected = 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66';
     $actual = $this->type->convertToDatabaseValue($uuid, $this->platform);
     $this->assertEquals($expected, $actual);
 }
开发者ID:scr-be,项目名称:arthur-doctrine-uuid-library,代码行数:7,代码来源:StringUuidTypeTest.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: it_should_create_video_proxy_from_the_video_source

 /**
  * @test
  */
 public function it_should_create_video_proxy_from_the_video_source()
 {
     $videoProxyService = new VideoProxyService($this->entityManager);
     $this->entityManager->expects($this->once())->method('persist');
     $proxyUuid = $videoProxyService->createFromSource("http://video-proxy.com");
     $this->assertEquals($proxyUuid, (string) Uuid::fromString($proxyUuid));
 }
开发者ID:erheme318,项目名称:simple-tv-listings,代码行数:10,代码来源:VideoProxyServiceTest.php

示例5: 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

示例6: deserializeUuid

 public function deserializeUuid(VisitorInterface $visitor, $data, array $type, Context $context)
 {
     if (null === $data) {
         return null;
     }
     return Uuid::fromString($data);
 }
开发者ID:pauci,项目名称:cqrs,代码行数:7,代码来源:RamseyUuidHandler.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: getList

 /**
  * @return JsonModel
  */
 public function getList()
 {
     $previousEventId = $this->params()->fromQuery('previousEventId');
     $count = $this->params()->fromQuery('count', 10);
     if ($previousEventId) {
         $previousEventId = Uuid::fromString($previousEventId);
     }
     $iterator = $this->eventStore->iterate($previousEventId);
     $selfUrl = $this->url()->fromRoute(null, [], ['force_canonical' => true], true);
     $nextUrl = false;
     $lastEventId = $previousEventId;
     $events = [];
     $i = 0;
     /** @var EventMessageInterface $event */
     foreach ($iterator as $event) {
         if ($i >= $count) {
             break;
         }
         $events[] = $event;
         $i++;
         $lastEventId = $event->getId()->toString();
     }
     $nextUrl = $this->url()->fromRoute(null, [], ['force_canonical' => true, 'query' => ['previousEventId' => (string) $lastEventId]], true);
     $data = ['_links' => ['self' => $selfUrl, 'next' => $nextUrl], 'count' => count($events), '_embedded' => ['event' => array_values($events)]];
     return new JsonModel($data);
 }
开发者ID:pauci,项目名称:cqrs-module,代码行数:29,代码来源:NotificationController.php

示例9: denormalize

 /**
  * @inheritdoc
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     if (null === $data) {
         return null;
     }
     return Uuid::fromString($data);
 }
开发者ID:gbprod,项目名称:uuid-normalizer,代码行数:10,代码来源:UuidDenormalizer.php

示例10: testSerializeJson

 public function testSerializeJson()
 {
     $uuid = Uuid::fromString('34ca79b8-6181-4b93-903a-ac658e0c5c35');
     $object = new ObjectWithUuid($uuid);
     $json = $this->serializer->serialize($object, 'json');
     $this->assertEquals('{"uuid":"34ca79b8-6181-4b93-903a-ac658e0c5c35"}', $json);
 }
开发者ID:pauci,项目名称:cqrs,代码行数:7,代码来源:RamseyUuidHandlerTest.php

示例11: convert

 public function convert($rawValue)
 {
     try {
         return Uuid::fromString($rawValue);
     } catch (\Exception $e) {
         return;
     }
 }
开发者ID:pawaclawczyk,项目名称:command-bus-launcher,代码行数:8,代码来源:UuidConverter.php

示例12: testUuidConvertsToPHPValue

 public function testUuidConvertsToPHPValue()
 {
     $uuid = $this->type->convertToPHPValue(hex2bin('ff6f8cb0c57d11e19b210800200c9a66'), $this->platform);
     $this->assertInstanceOf('Ramsey\\Uuid\\Uuid', $uuid);
     $this->assertEquals('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
     $uuid = $this->type->convertToPHPValue('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $this->platform);
     $this->assertEquals('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66')->toString());
 }
开发者ID:scr-be,项目名称:arthur-doctrine-uuid-library,代码行数:8,代码来源:BinaryUuidTypeTest.php

示例13: it_returns_command_with_uuid_to_launch

 /**
  * @test
  */
 public function it_returns_command_with_uuid_to_launch()
 {
     $this->commandCollector->getCommandByName('DummyCommandWithUuid')->willReturn(CommandReflection::fromClass(DummyCommandWithUuid::class));
     $this->argumentsProcessor->process(['lorem ipsum', 'a1df6294-bcd9-43c5-8731-e3cd43401974'])->willReturn(['lorem ipsum', Uuid::fromString('a1df6294-bcd9-43c5-8731-e3cd43401974')]);
     $command = $this->sut->getCommandToLaunch('DummyCommandWithUuid', ['lorem ipsum', 'a1df6294-bcd9-43c5-8731-e3cd43401974']);
     $this->assertInstanceOf(DummyCommandWithUuid::class, $command);
     $this->assertTrue(Uuid::fromString('a1df6294-bcd9-43c5-8731-e3cd43401974')->equals($command->argument2));
 }
开发者ID:pawaclawczyk,项目名称:command-bus-launcher,代码行数:11,代码来源:CommandLauncherTest.php

示例14: addReservation

 protected function addReservation($reservationId, $bookId, \DateTime $givenAwayAt = null)
 {
     $reservation = new Reservation(Uuid::fromString($reservationId), Uuid::fromString($bookId), 'john@doe.com');
     if (null !== $givenAwayAt) {
         $reservation->giveAway($givenAwayAt);
     }
     $this->reservations->save($reservation);
 }
开发者ID:ClearcodeHQ,项目名称:eh-library-sandbox-slim,代码行数:8,代码来源:WebTestCase.php

示例15: 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


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