From 3e6ee5ecdc21fa0308cc2f6f042c50cd55706b1f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 12 Jul 2017 20:18:22 +0200 Subject: [PATCH] Fix bugs from draft --- .../Exceptions/InvalidSignatureException.php | 47 +++++++++++++++++++ Models/Exceptions/InvalidVersionException.php | 47 +++++++++++++++++++ Models/Package.php | 8 ++-- ...kageInfoManager => PackageInfoManager.php} | 0 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 Models/Exceptions/InvalidSignatureException.php create mode 100644 Models/Exceptions/InvalidVersionException.php rename Models/{PackageInfoManager => PackageInfoManager.php} (100%) diff --git a/Models/Exceptions/InvalidSignatureException.php b/Models/Exceptions/InvalidSignatureException.php new file mode 100644 index 0000000..eb59a9b --- /dev/null +++ b/Models/Exceptions/InvalidSignatureException.php @@ -0,0 +1,47 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); + +namespace Modules\Admin\Models\Exceptions; + +/** + * Permission exception class. + * + * @category Framework + * @package phpOMS\System\File + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class InvalidSignatureException extends \RuntimeException +{ + /** + * Constructor. + * + * @param string $message Exception message + * @param int $code Exception code + * @param \Exception Previous exception + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct(string $message, int $code = 0, \Exception $previous = null) + { + parent::__construct('Signature "' . $message . '" is invalid.', $code, $previous); + } +} diff --git a/Models/Exceptions/InvalidVersionException.php b/Models/Exceptions/InvalidVersionException.php new file mode 100644 index 0000000..e241ea9 --- /dev/null +++ b/Models/Exceptions/InvalidVersionException.php @@ -0,0 +1,47 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); + +namespace Modules\Admin\Models\Exceptions; + +/** + * Permission exception class. + * + * @category Framework + * @package phpOMS\System\File + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class InvalidVersionException extends \RuntimeException +{ + /** + * Constructor. + * + * @param string $message Exception message + * @param int $code Exception code + * @param \Exception Previous exception + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct(string $message, int $code = 0, \Exception $previous = null) + { + parent::__construct('Version "' . $message . '" is invalid.', $code, $previous); + } +} diff --git a/Models/Package.php b/Models/Package.php index b7c3e9b..0430459 100644 --- a/Models/Package.php +++ b/Models/Package.php @@ -17,6 +17,8 @@ declare(strict_types=1); namespace Modules\Admin\Models; use phpOMS\Utils\IO\Zip\Zip; +use Modules\Admin\Models\Exceptions\InvalidSignatureException; +use Modules\Admin\Models\Exceptions\InvalidVersionException; class Package { @@ -38,14 +40,14 @@ class Package return true; } - public function validated() : bool; + public function validated() : bool { if(!$this->validateSignature()) { - throw new InvalidSignature(); + throw new InvalidSignatureException(); } if(!$this->validateVersion()) { - throw new InvalidVersion(); + throw new InvalidVersionException(); } return true; diff --git a/Models/PackageInfoManager b/Models/PackageInfoManager.php similarity index 100% rename from Models/PackageInfoManager rename to Models/PackageInfoManager.php