partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 4f8c906e5d45c979ae64db8731cd4d66d4104ec9
parent 61d0be3c92a7f6f63a438fb5e480fd454497483d
Author: Timo A. Hummel <timo@netraver.de>
Date:   Mon,  6 Jun 2011 16:31:49 +0200

Added check for negative minimum stock value levels

Diffstat:
Msrc/de/RaumZeitLabor/PartDB2/Part/Part.php | 11++++++++++-
Asrc/de/RaumZeitLabor/PartDB2/Util/Exceptions/OutOfRangeException.php | 7+++++++
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/de/RaumZeitLabor/PartDB2/Part/Part.php b/src/de/RaumZeitLabor/PartDB2/Part/Part.php @@ -2,7 +2,9 @@ namespace de\RaumZeitLabor\PartDB2\Part; declare(encoding = 'UTF-8'); -use de\RaumZeitLabor\PartDB2\PartDB2; +use de\RaumZeitLabor\PartDB2\PartDB2, + de\RaumZeitLabor\PartDB2\Util\Exceptions\OutOfRangeException; + /** @Entity **/ class Part { @@ -80,6 +82,13 @@ class Part { } public function setMinStockLevel ($minStockLevel) { + $minStockLevel = intval($minStockLevel); + + if ($minStockLevel < 0) { + $exception = new OutOfRangeException(PartDB2::i18n("Minimum Stock Level is out of range")); + $exception->setDetail(PartDB2::i18n("The minimum stock level must be 0 or higher")); + throw $exception; + } $this->minStockLevel = $minStockLevel; } diff --git a/src/de/RaumZeitLabor/PartDB2/Util/Exceptions/OutOfRangeException.php b/src/de/RaumZeitLabor/PartDB2/Util/Exceptions/OutOfRangeException.php @@ -0,0 +1,7 @@ +<?php +namespace de\RaumZeitLabor\PartDB2\Util\Exceptions; +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartDB2\Util\SerializableException; + +class OutOfRangeException extends SerializableException {}