From ea1677519a15e8b3614a61d468295d6ab68e2a8f Mon Sep 17 00:00:00 2001 From: recursive_tree Date: Thu, 28 Mar 2024 16:14:58 +0100 Subject: [PATCH] feat: add HasTypeIDWithAmount interface --- src/Contracts/HasTypeIDWithAmount.php | 15 +++++++++++++ src/Contracts/IPriceable.php | 7 +----- src/Items/EveTypeWithAmount.php | 32 +++++++++++++++++++++++++++ src/Items/PriceableEveType.php | 19 +++++----------- 4 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 src/Contracts/HasTypeIDWithAmount.php create mode 100644 src/Items/EveTypeWithAmount.php diff --git a/src/Contracts/HasTypeIDWithAmount.php b/src/Contracts/HasTypeIDWithAmount.php new file mode 100644 index 00000000..ebd3ada2 --- /dev/null +++ b/src/Contracts/HasTypeIDWithAmount.php @@ -0,0 +1,15 @@ +amount = $amount; + } + + /** + * @return int The amount of items + */ + public function getAmount(): int + { + return $this->amount; + } +} \ No newline at end of file diff --git a/src/Items/PriceableEveType.php b/src/Items/PriceableEveType.php index dbe6b95b..18662f56 100644 --- a/src/Items/PriceableEveType.php +++ b/src/Items/PriceableEveType.php @@ -23,33 +23,24 @@ namespace Seat\Services\Items; use Seat\Services\Contracts\HasTypeID; +use Seat\Services\Contracts\HasTypeIDWithAmount; use Seat\Services\Contracts\IPriceable; /** * A basic implementation od IPriceable. */ -class PriceableEveType extends EveType implements IPriceable +class PriceableEveType extends EveTypeWithAmount implements IPriceable { protected float $price; - protected float $amount; /** * @param int|HasTypeID $type_id The eve type to be appraised - * @param float $amount The amount of this type to be appraised + * @param float|int $amount The amount of this type to be appraised */ - public function __construct(int|HasTypeID $type_id, float $amount) + public function __construct(int|HasTypeID $type_id, float|int $amount) { - parent::__construct($type_id); + parent::__construct($type_id, (int) $amount); $this->price = 0; - $this->amount = $amount; - } - - /** - * @return int The amount of this item to be appraised - */ - public function getAmount(): int - { - return $this->amount; } /**