From f378db384c9cd960ff596bf49e89506116a5b3cf Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:49:07 +0200 Subject: [PATCH] feat: add HasTypeIDWithAmount interface (#180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add HasTypeIDWithAmount interface * styleci * Update src/Contracts/IPriceable.php Remove redundant extends Co-authored-by: Loïc Leuilliot --------- Co-authored-by: Crypta Eve Co-authored-by: Loïc Leuilliot --- src/Contracts/HasTypeIDWithAmount.php | 35 ++++++++++++++++++ src/Contracts/IPriceable.php | 7 +--- src/Items/EveTypeWithAmount.php | 52 +++++++++++++++++++++++++++ src/Items/PriceableEveType.php | 18 +++------- 4 files changed, 92 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..5d46d9d8 --- /dev/null +++ b/src/Contracts/HasTypeIDWithAmount.php @@ -0,0 +1,35 @@ +amount = $amount; + } + + /** + * @return int The amount of items + */ + public function getAmount(): int + { + return $this->amount; + } +} diff --git a/src/Items/PriceableEveType.php b/src/Items/PriceableEveType.php index dbe6b95b..6d00de93 100644 --- a/src/Items/PriceableEveType.php +++ b/src/Items/PriceableEveType.php @@ -28,28 +28,18 @@ /** * 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; } /**