本文整理匯總了PHP中Rhumsaa\Uuid\Uuid::fromString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uuid::fromString方法的具體用法?PHP Uuid::fromString怎麽用?PHP Uuid::fromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Rhumsaa\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::fromString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: it_should_generate_a_version_4_uuid
/**
* @test
*/
public function it_should_generate_a_version_4_uuid()
{
$generator = new Version4Generator();
$uuid = $generator->generate();
$uuidObject = Uuid::fromString($uuid);
$this->assertEquals(4, $uuidObject->getVersion());
}
示例2: setUpBeforeClass
/**
* @inheritdoc
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
foreach (self::$uuids as $i => $uuid) {
self::$uuids[$i] = Uuid::fromString($uuid);
}
}
示例3: testParseWithUuidTagHandler
function testParseWithUuidTagHandler()
{
$expected = [Uuid::fromString('f81d4fae-7dec-11d0-a765-00a0c91e6bf6')];
$edn = '#uuid "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"';
$data = igorw\edn\parse($edn);
$this->assertEquals($expected, $data);
}
示例4: testUuidConvertsToDatabaseValue
/**
* @covers Rhumsaa\Uuid\Doctrine\UuidType::convertToDatabaseValue
*/
public function testUuidConvertsToDatabaseValue()
{
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$expected = $uuid->toString();
$actual = $this->type->convertToDatabaseValue($uuid, $this->platform);
$this->assertEquals($expected, $actual);
}
示例5: fromString
/**
* {@inheritdoc}
*
* @return static
*/
public static function fromString($id)
{
if (null === $id) {
return null;
}
return new static(Uuid::fromString($id));
}
示例6: testDenormalize
public function testDenormalize()
{
$obj = Uuid::fromString('6d6f9c73-1f59-4235-ace1-3bccd789315d');
$str = '6d6f9c73-1f59-4235-ace1-3bccd789315d';
self::assertEquals($obj, $this->normalizer->denormalize($str, 'json'));
self::assertEquals($obj, $this->normalizer->denormalize($str, 'xml'));
}
示例7: getIdentifier
/**
* Get identifier
*
* @return Uuid
*/
public function getIdentifier()
{
if (is_null($this->identifier)) {
return Uuid::fromString(Uuid::NIL);
}
return $this->identifier;
}
示例8: denormalize
/**
* @inheritdoc
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
if ($data === null) {
return null;
}
return Uuid::fromString($data);
}
示例9: execute
public function execute()
{
parent::execute();
try {
$id = Uuid::fromString($this->getParameter('id', 'string'));
$teamMember = $this->get('team_repository')->find($id);
} catch (\Exception $e) {
return $this->redirect(Model::createURLForAction('Index') . '&error=non-existing');
}
$form = new TeamType('edit', $teamMember);
if ($form->handle()) {
$teamMember = $form->getData();
$this->get('team_repository')->save($teamMember);
return $this->redirect(Model::createURLForAction('Index') . '&report=edited' . '&highlight=row-' . $teamMember->getId());
}
// assign the detail url to the template if available
$url = Model::getURLForBlock($this->URL->getModule(), 'Detail');
if (Model::getURL(404) != $url) {
$this->tpl->assign('detailURL', SITE_URL . $url);
}
$form->parse($this->tpl);
$this->tpl->assign('teamMember', $teamMember->toArray());
$this->parse();
$this->display();
}
示例10: get
/**
* @param string $id
* @return mixed
*/
public function get($id)
{
$message = $this->messageLogger->getEntryForMessageId(Uuid::fromString($id));
if (is_null($message)) {
return new ApiProblemResponse(new ApiProblem(404, "Message can not be found"));
}
return ["message" => $message->toArray()];
}
示例11: fromString
/**
* @param string $string
* @return static
*/
public static function fromString($string)
{
try {
return new static(RamseyUuid::fromString($string));
} catch (\InvalidArgumentException $e) {
throw InvalidUuid::create($string, $e);
}
}
示例12: array
function it_is_equal_to_statement_ids_with_equal_value()
{
$value = '39e24cc4-69af-4b01-a824-1fdc6ea8a3af';
$uuid = Uuid::fromString($value);
$this->beConstructedThrough('fromUuid', array($uuid));
$this->equals(StatementId::fromString($value))->shouldReturn(true);
$this->equals(StatementId::fromUuid(Uuid::fromString($value)))->shouldReturn(true);
$this->equals(StatementId::fromUuid($uuid))->shouldReturn(true);
}
示例13: __construct
/**
* @param string
*/
public final function __construct($uuid)
{
if (!is_string($uuid)) {
throw new InvalidArgumentException('Uuid expected a string.');
}
if (!\Rhumsaa\Uuid\Uuid::isValid($uuid)) {
throw new InvalidArgumentException('Invalid Uuid format.');
}
$this->uuid = \Rhumsaa\Uuid\Uuid::fromString($uuid);
}
示例14: deserializeUuid
public function deserializeUuid(VisitorInterface $visitor, $data, array $type, Context $context)
{
if (null === $data) {
return null;
}
if (!preg_match('/^' . self::UUID_V4_PATTERN . '$/', $data)) {
throw new Exception\RuntimeException('Invalid UUID version 4 format');
}
$uuid = Uuid::fromString($data);
return $uuid;
}
示例15: refundReturnAction
/**
* @Route("/returns/refund", name="refund_return")
* @Method("POST")
*/
public function refundReturnAction(Request $request)
{
$returnNumber = new ReturnNumber(Uuid::fromString($request->request->get('return_number')));
if ('credit' == $request->request->get('return_type')) {
$command = new RefundForCredit($returnNumber);
} else {
$command = new RefundForCash($returnNumber);
}
$this->get('symfony_live.pos.command_bus')->dispatch($command);
return $this->redirect($this->generateUrl('outstanding'));
}