Make part of the api oo and create oo skeleton

This commit is contained in:
Tim
2021-04-16 01:23:55 +02:00
parent 8f88a863d1
commit 91d9a5a61f
9 changed files with 487 additions and 4 deletions

View File

@ -0,0 +1,98 @@
<?php
namespace Ardent\PicnicApi\Objects;
class SingleArticle extends AbstractApiObject
{
static public function getType(): string
{
return 'SINGLE_ARTICLE';
}
/**
* SingleArticle constructor.
*/
public function __construct(
private string $id,
private string $name,
private int $price,
private int $displayPrice,
private string $imageId,
private int $maxCount,
private string $unitQuantity,
)
{
}
static public function fromApi(array $apiObject): self
{
return new self(
$apiObject['id'],
$apiObject['name'],
$apiObject['price'],
$apiObject['display_price'],
$apiObject['image_id'],
$apiObject['max_count'],
$apiObject['unit_quantity'],
);
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return int
*/
public function getPrice(): int
{
return $this->price;
}
/**
* @return int
*/
public function getDisplayPrice(): int
{
return $this->displayPrice;
}
/**
* @return string
*/
public function getImageId(): string
{
return $this->imageId;
}
/**
* @return int
*/
public function getMaxCount(): int
{
return $this->maxCount;
}
/**
* @return string
*/
public function getUnitQuantity(): string
{
return $this->unitQuantity;
}
}