/** * @param array|ItemCollection $items * @return ItemCollection */ private function ensureItemsInstance($items) { if ($items instanceof ItemCollection) { return $items; } if (!is_array($items)) { throw new \InvalidArgumentException('Invalid items data'); } return ItemCollection::factory($items); }
/** * Create Item Collection Instance * @param array $data * @return ItemCollection */ public function createCollection(array $data = []) { return ItemCollection::factory($data); }
/** * Get Items * @return ItemCollection */ public function getItems() { $data = $this->data['items']['item']; if (1 == $this->data['itemCount']) { $data = [$this->data['items']['item']]; } $items = ItemCollection::factory($data); return $items; }
/** * Test With Empty Data */ public function testWithEmpty() { $o = ItemCollection::factory(); $this->assertInstanceOf(ItemCollection::class, $o); $this->assertCount(0, $o); }
/** * Test With Empty Data */ public function testWithEmpty() { $collection = ItemCollection::factory(); $this->assertInstanceOf('\\laravel\\pagseguro\\Item\\ItemCollection', $collection); $this->assertCount(0, $collection); }
/** * Set Item Collection From Array Type (Set itens da requisição de pagamento) * @param array $itemCollection * @author Isaque de Souza <*****@*****.**> * @return Payment */ public function setItemCollectionFromArray(array $itemCollection) { $collection = ItemCollection::factory($itemCollection); $this->setItemCollection($collection); return $this; }