本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例5: testGenerate
public function testGenerate()
{
$id = UuidIdentifier::generate();
$this->assertTrue(Uuid::isValid($id));
$uuid = Uuid::fromString($id->toString());
$this->assertTrue($uuid->getVersion() == 4);
}
示例6: deserializeUuid
public function deserializeUuid(VisitorInterface $visitor, $data, array $type, Context $context)
{
if (null === $data) {
return null;
}
return Uuid::fromString($data);
}
示例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());
}
示例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);
}
示例9: denormalize
/**
* @inheritdoc
*/
public function denormalize($data, $class, $format = null, array $context = array())
{
if (null === $data) {
return null;
}
return Uuid::fromString($data);
}
示例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);
}
示例11: convert
public function convert($rawValue)
{
try {
return Uuid::fromString($rawValue);
} catch (\Exception $e) {
return;
}
}
示例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());
}
示例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));
}
示例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);
}
示例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;
}