Throw exception on invalid parameters on Inventory addItem() and removeItem()

This commit is contained in:
Shoghi Cervantes 2015-06-07 12:05:10 +02:00
parent cf3f32fdae
commit e5f28e0f7a
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89

View File

@ -236,6 +236,9 @@ abstract class BaseInventory implements Inventory{
/** @var Item[] $slots */
$itemSlots = [];
foreach($slots as $slot){
if(!($slot instanceof Item)){
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
}
if($slot->getId() !== 0 and $slot->getCount() > 0){
$itemSlots[] = clone $slot;
}
@ -293,6 +296,9 @@ abstract class BaseInventory implements Inventory{
/** @var Item[] $slots */
$itemSlots = [];
foreach($slots as $slot){
if(!($slot instanceof Item)){
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
}
if($slot->getId() !== 0 and $slot->getCount() > 0){
$itemSlots[] = clone $slot;
}