Make part of the api oo and create oo skeleton
This commit is contained in:
98
src/Objects/SingleArticle.php
Normal file
98
src/Objects/SingleArticle.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user