本文整理汇总了PHP中Price::fromJson方法的典型用法代码示例。如果您正苦于以下问题:PHP Price::fromJson方法的具体用法?PHP Price::fromJson怎么用?PHP Price::fromJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Price
的用法示例。
在下文中一共展示了Price::fromJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromJson
public static function fromJson($json)
{
$r = new Checkout();
$r->setItems(array_map(function ($json) {
return CheckoutItem::fromJson($json);
}, $json->items));
$r->setTotal(Price::fromJson($json->total));
return $r;
}
示例2: fromJson
public static function fromJson($json)
{
$r = new CheckoutItem();
$r->setCount($json->count);
$r->setName(isset($json->name) ? $json->name : null);
$r->setSku($json->sku);
$r->setExternalId(isset($json->external_id) ? $json->external_id : null);
$r->setPrice(Price::fromJson($json->price));
$r->setTotal(Price::fromJson($json->total));
return $r;
}
示例3: fromJson
public static function fromJson($json)
{
if (!isset($json->item) && !isset($json->checkout)) {
throw new \Exception('both checkout and item are null');
}
if (isset($json->item) && isset($json->checkout)) {
throw new \Exception('both checkout and item are non-null, only expected one of checkout or item');
}
$r = new Transaction();
$r->setId($json->id);
$r->setExternalId(isset($json->external_id) ? $json->external_id : null);
$r->setCreated($json->created);
$r->setState($json->state);
$r->setRevisionNumber($json->revision_number);
$r->setProject($json->project);
$r->setItem(isset($json->item) ? Item::fromJson($json->item) : null);
$r->setCheckout(isset($json->checkout) ? Checkout::fromJson($json->checkout) : null);
$r->setCustomer(Customer::fromJson($json->customer));
$r->setPrice(Price::fromJson($json->price));
$r->setPaymentMethod($json->payment_method);
$r->setTest(isset($json->test) ? $json->test : false);
return $r;
}