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 @@
namespace QUI\ERP\Coupons;
use QUI\ERP\Order\OrderInterface;
use function GuzzleHttp\Promise\queue;
use QUI;
use QUI\ERP\Order\OrderInterface;
use QUI\Permissions\Permission;
use QUI\ERP\Discount\Handler as DiscountHandler;
......@@ -94,16 +93,28 @@ class CouponCode
* CouponCode constructor.
*
* @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([
'from' => Handler::getTable(),
'where' => [
'id' => $id
]
]);
try {
$result = QUI::getDataBase()->fetch([
'from' => Handler::getTable(),
'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)) {
throw new CouponCodeException([
......@@ -153,7 +164,7 @@ public function __construct($id)
/**
* @return int
*/
public function getId()
public function getId(): int
{
return $this->id;
}
......@@ -161,7 +172,7 @@ public function getId()
/**
* @return string
*/
public function getCode()
public function getCode(): string
{
return $this->code;
}
......@@ -169,7 +180,7 @@ public function getCode()
/**
* @return \DateTime
*/
public function getCreateDate()
public function getCreateDate(): \DateTime
{
return $this->CreateDate;
}
......@@ -179,7 +190,7 @@ public function getCreateDate()
*
* @return array
*/
public function getUsages()
public function getUsages(): array
{
return $this->usages;
}
......@@ -187,7 +198,7 @@ public function getUsages()
/**
* @return \DateTime|null
*/
public function getValidUntilDate()
public function getValidUntilDate(): ?\DateTime
{
return $this->ValidUntilDate;
}
......@@ -195,7 +206,7 @@ public function getValidUntilDate()
/**
* @return string
*/
public function getTitle()
public function getTitle(): ?string
{
return $this->title;
}
......@@ -203,7 +214,7 @@ public function getTitle()
/**
* @return int[]
*/
public function getDiscountIds()
public function getDiscountIds(): array
{
return $this->discountIds;
}
......@@ -213,7 +224,7 @@ public function getDiscountIds()
*
* @return QUI\ERP\Discount\Discount[]
*/
public function getDiscounts()
public function getDiscounts(): array
{
$discounts = [];
$DiscountHandler = DiscountHandler::getInstance();
......@@ -454,7 +465,7 @@ public function checkOrderRedemption($Order)
* @param OrderInterface $Order
* @return bool
*/
public function isRedeemable($User = null, $Order = null)
public function isRedeemable($User = null, $Order = null): bool
{
try {
$this->checkRedemption($User);
......@@ -480,7 +491,7 @@ public function isRedeemable($User = null, $Order = null)
*
* @return bool
*/
public function isValid()
public function isValid(): bool
{
return $this->valid;
}
......@@ -491,7 +502,7 @@ public function isValid()
* @param QUI\Interfaces\Users\User $User
* @return bool
*/
public function hasUserRedeemed($User)
public function hasUserRedeemed(QUI\Interfaces\Users\User $User): bool
{
$userId = $User->getId();
......@@ -514,10 +525,14 @@ public function delete()
{
Permission::checkPermission(Handler::PERMISSION_DELETE);
QUI::getDataBase()->delete(
Handler::getTable(),
['id' => $this->id]
);
try {
QUI::getDataBase()->delete(
Handler::getTable(),
['id' => $this->id]
);
} catch (QUI\DataBase\Exception $Exception) {
QUI\System\Log::addError($Exception->getMessage());
}
}
/**
......@@ -525,7 +540,7 @@ public function delete()
*
* @return array
*/
public function toArray()
public function toArray(): array
{
$data = [
'id' => $this->getId(),
......@@ -682,7 +697,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
}
/**
* @param QUI\ERP\Accounting\Articles\Text $Article
* @param $Article
* @return boolean
*/
$isInArticles = function ($Article) use ($Order) {
......@@ -712,7 +727,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
};
foreach ($articles as $Article) {
/* @var $PriceFactor QUI\ERP\Accounting\Invoice\Articles\Text */
/* @var $PriceFactor QUI\ERP\Accounting\Articles\Text */
if ($isInArticles($Article) === false) {
$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