for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Billogram\Model\Invoice;
use Billogram\Model\CreatableFromArray;
use Billogram\Model\Item\BaseItem;
use Billogram\Model\Item\Bookkeeping;
/**
* @author Ibrahim Hizeoui <[email protected]>
*/
class Item extends BaseItem implements CreatableFromArray
{
* @var int count
private $count;
* @var int
private $discount;
* @return int
public function getCount(): int
return $this->count;
}
* @param int $count
*
* @return Item
public function withCount(int $count)
$new = clone $this;
$new->count = $count;
return $new;
public function getDiscount(): int
return $this->discount;
* @param int $discount
public function withDiscount(int $discount)
$new->discount = $discount;
public function toArray()
$data = parent::toArray();
if ($this->count !== null) {
$data['count'] = $this->count;
if ($this->discount !== null) {
$data['discount'] = $this->discount;
return $data;
public static function createFromArray(array $data)
$item = new self();
$item->count = $data['count'] ?? null;
$item->discount = $data['discount'] ?? null;
$item->itemNo = $data['item_no'] ?? null;
$item->title = $data['title'] ?? null;
$item->description = $data['description'] ?? null;
$item->price = $data['price'] ?? null;
$item->vat = $data['vat'] ?? null;
$item->unit = $data['unit'] ?? null;
$item = $item->withBookkeeping(Bookkeeping::createFromArray($data['bookkeeping'])) ?? null;
return $item;