Skip to content
Code-Schnipsel Gruppen Projekte
Commit 6e822f7d erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: return hints

Übergeordneter 0997886c
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
namespace QUI\ERP\Coupons; namespace QUI\ERP\Coupons;
use QUI\ERP\Order\OrderInterface;
use function GuzzleHttp\Promise\queue;
use QUI; use QUI;
use QUI\ERP\Order\OrderInterface;
use QUI\Permissions\Permission; use QUI\Permissions\Permission;
use QUI\ERP\Discount\Handler as DiscountHandler; use QUI\ERP\Discount\Handler as DiscountHandler;
...@@ -94,16 +93,28 @@ class CouponCode ...@@ -94,16 +93,28 @@ class CouponCode
* CouponCode constructor. * CouponCode constructor.
* *
* @param int $id - Invite Code ID * @param int $id - Invite Code ID
* @throws \QUI\ERP\Coupons\CouponCodeException * @throws CouponCodeException
*/ */
public function __construct($id) public function __construct(int $id)
{ {
$result = QUI::getDataBase()->fetch([ try {
'from' => Handler::getTable(), $result = QUI::getDataBase()->fetch([
'where' => [ 'from' => Handler::getTable(),
'id' => $id 'where' => [
] 'id' => $id
]); ]
]);
} catch (QUI\DataBase\Exception $Exception) {
QUI\System\Log::addError($Exception->getMessage());
throw new CouponCodeException([
'quiqqer/coupons',
'exception.CouponCode.not_found',
[
'id' => $id
]
], 404);
}
if (empty($result)) { if (empty($result)) {
throw new CouponCodeException([ throw new CouponCodeException([
...@@ -153,7 +164,7 @@ public function __construct($id) ...@@ -153,7 +164,7 @@ public function __construct($id)
/** /**
* @return int * @return int
*/ */
public function getId() public function getId(): int
{ {
return $this->id; return $this->id;
} }
...@@ -161,7 +172,7 @@ public function getId() ...@@ -161,7 +172,7 @@ public function getId()
/** /**
* @return string * @return string
*/ */
public function getCode() public function getCode(): string
{ {
return $this->code; return $this->code;
} }
...@@ -169,7 +180,7 @@ public function getCode() ...@@ -169,7 +180,7 @@ public function getCode()
/** /**
* @return \DateTime * @return \DateTime
*/ */
public function getCreateDate() public function getCreateDate(): \DateTime
{ {
return $this->CreateDate; return $this->CreateDate;
} }
...@@ -179,7 +190,7 @@ public function getCreateDate() ...@@ -179,7 +190,7 @@ public function getCreateDate()
* *
* @return array * @return array
*/ */
public function getUsages() public function getUsages(): array
{ {
return $this->usages; return $this->usages;
} }
...@@ -187,7 +198,7 @@ public function getUsages() ...@@ -187,7 +198,7 @@ public function getUsages()
/** /**
* @return \DateTime|null * @return \DateTime|null
*/ */
public function getValidUntilDate() public function getValidUntilDate(): ?\DateTime
{ {
return $this->ValidUntilDate; return $this->ValidUntilDate;
} }
...@@ -195,7 +206,7 @@ public function getValidUntilDate() ...@@ -195,7 +206,7 @@ public function getValidUntilDate()
/** /**
* @return string * @return string
*/ */
public function getTitle() public function getTitle(): ?string
{ {
return $this->title; return $this->title;
} }
...@@ -203,7 +214,7 @@ public function getTitle() ...@@ -203,7 +214,7 @@ public function getTitle()
/** /**
* @return int[] * @return int[]
*/ */
public function getDiscountIds() public function getDiscountIds(): array
{ {
return $this->discountIds; return $this->discountIds;
} }
...@@ -213,7 +224,7 @@ public function getDiscountIds() ...@@ -213,7 +224,7 @@ public function getDiscountIds()
* *
* @return QUI\ERP\Discount\Discount[] * @return QUI\ERP\Discount\Discount[]
*/ */
public function getDiscounts() public function getDiscounts(): array
{ {
$discounts = []; $discounts = [];
$DiscountHandler = DiscountHandler::getInstance(); $DiscountHandler = DiscountHandler::getInstance();
...@@ -454,7 +465,7 @@ public function checkOrderRedemption($Order) ...@@ -454,7 +465,7 @@ public function checkOrderRedemption($Order)
* @param OrderInterface $Order * @param OrderInterface $Order
* @return bool * @return bool
*/ */
public function isRedeemable($User = null, $Order = null) public function isRedeemable($User = null, $Order = null): bool
{ {
try { try {
$this->checkRedemption($User); $this->checkRedemption($User);
...@@ -480,7 +491,7 @@ public function isRedeemable($User = null, $Order = null) ...@@ -480,7 +491,7 @@ public function isRedeemable($User = null, $Order = null)
* *
* @return bool * @return bool
*/ */
public function isValid() public function isValid(): bool
{ {
return $this->valid; return $this->valid;
} }
...@@ -491,7 +502,7 @@ public function isValid() ...@@ -491,7 +502,7 @@ public function isValid()
* @param QUI\Interfaces\Users\User $User * @param QUI\Interfaces\Users\User $User
* @return bool * @return bool
*/ */
public function hasUserRedeemed($User) public function hasUserRedeemed(QUI\Interfaces\Users\User $User): bool
{ {
$userId = $User->getId(); $userId = $User->getId();
...@@ -514,10 +525,14 @@ public function delete() ...@@ -514,10 +525,14 @@ public function delete()
{ {
Permission::checkPermission(Handler::PERMISSION_DELETE); Permission::checkPermission(Handler::PERMISSION_DELETE);
QUI::getDataBase()->delete( try {
Handler::getTable(), QUI::getDataBase()->delete(
['id' => $this->id] Handler::getTable(),
); ['id' => $this->id]
);
} catch (QUI\DataBase\Exception $Exception) {
QUI\System\Log::addError($Exception->getMessage());
}
} }
/** /**
...@@ -525,7 +540,7 @@ public function delete() ...@@ -525,7 +540,7 @@ public function delete()
* *
* @return array * @return array
*/ */
public function toArray() public function toArray(): array
{ {
$data = [ $data = [
'id' => $this->getId(), 'id' => $this->getId(),
...@@ -682,7 +697,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order) ...@@ -682,7 +697,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
} }
/** /**
* @param QUI\ERP\Accounting\Articles\Text $Article * @param $Article
* @return boolean * @return boolean
*/ */
$isInArticles = function ($Article) use ($Order) { $isInArticles = function ($Article) use ($Order) {
...@@ -712,7 +727,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order) ...@@ -712,7 +727,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
}; };
foreach ($articles as $Article) { foreach ($articles as $Article) {
/* @var $PriceFactor QUI\ERP\Accounting\Invoice\Articles\Text */ /* @var $PriceFactor QUI\ERP\Accounting\Articles\Text */
if ($isInArticles($Article) === false) { if ($isInArticles($Article) === false) {
$Order->addArticle($Article); $Order->addArticle($Article);
} }
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren