本文整理匯總了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;
}