Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public function testBuildWithoutNameFails()
 {
     $item = CheckoutItem::of(1, 'SKU')->setPrice(['EUR' => '10.00']);
     try {
         $item->build();
         $this->fail();
     } catch (\LogicException $expected) {
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public function testBuildWithoutTotal()
 {
     $checkout = new Checkout();
     $checkout->addItem(CheckoutItem::of(1, 'SKU')->setExternalId('external_id')->setName(['en' => 'Name'])->setPrice(['EUR' => '10.0']));
     try {
         $checkout->build();
         $this->fail();
     } catch (\LogicException $ignored) {
     }
 }