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

refactor: code performance

Übergeordneter 6469fb97
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -57,7 +57,7 @@ public function __construct($id, Handler $Factory)
// cleanup user group save
$cleanup = QUI\Utils\ArrayHelper::cleanup($this->getAttribute('user_groups'));
$cleanup = implode(',', $cleanup);
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
......@@ -68,7 +68,7 @@ public function __construct($id, Handler $Factory)
// cleanup product(s)
$cleanup = QUI\Utils\ArrayHelper::cleanup($this->getAttribute('articles'));
$cleanup = implode(',', $cleanup);
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
......@@ -79,7 +79,7 @@ public function __construct($id, Handler $Factory)
// cleanup user group save
$cleanup = QUI\Utils\ArrayHelper::cleanup($this->getAttribute('user_groups'));
$cleanup = implode(',', $cleanup);
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
......@@ -90,7 +90,7 @@ public function __construct($id, Handler $Factory)
// cleanup product(s)
$cleanup = QUI\Utils\ArrayHelper::cleanup($this->getAttribute('articles'));
$cleanup = implode(',', $cleanup);
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
......@@ -264,9 +264,9 @@ public function canCombinedWith(Discount $Discount)
return false;
}
$combine = implode($combine, ',');
$combine = \implode($combine, ',');
if (!is_array($combine)) {
if (!\is_array($combine)) {
return false;
}
......@@ -294,13 +294,13 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
// usage definitions / limits
$dateFrom = $this->getAttribute('date_from');
$dateUntil = $this->getAttribute('date_until');
$now = time();
$now = \time();
if ($dateFrom && strtotime($dateFrom) > $now) {
if ($dateFrom && \strtotime($dateFrom) > $now) {
return false;
}
if ($dateUntil && strtotime($dateUntil) < $now) {
if ($dateUntil && \strtotime($dateUntil) < $now) {
return false;
}
......@@ -367,12 +367,12 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
$articles = $this->getAttribute('articles');
$categories = $this->getAttribute('categories');
if (is_string($articles)) {
$articles = explode(',', $articles);
if (\is_string($articles)) {
$articles = \explode(',', $articles);
}
if (is_string($categories)) {
$categories = explode(',', $categories);
if (\is_string($categories)) {
$categories = \explode(',', $categories);
}
......@@ -392,7 +392,7 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
if (empty($categories)) {
return true;
}
foreach ($categories as $category) {
$productCategories = $Product->getCategories();
......
......@@ -35,7 +35,7 @@ class EventHandling
*/
protected static function getHandler()
{
if (is_null(self::$Handler)) {
if (self::$Handler === null) {
self::$Handler = new Handler();
}
......@@ -140,11 +140,11 @@ public static function onQuiqqerProductsCalcListProduct(
) {
$userDiscounts = self::getUserDiscounts($Calc->getUser());
if (!is_array($userDiscounts)) {
if (!\is_array($userDiscounts) || empty($userDiscounts)) {
return;
}
$userDiscounts = array_filter($userDiscounts, function ($Discount) {
$userDiscounts = \array_filter($userDiscounts, function ($Discount) {
/* @var $Discount Discount */
// don't use manuel usage type
......@@ -155,7 +155,7 @@ public static function onQuiqqerProductsCalcListProduct(
return $Discount->getAttribute('scope') == Handler::DISCOUNT_SCOPE_EVERY_PRODUCT;
});
if (!is_array($userDiscounts)) {
if (!\is_array($userDiscounts) || empty($userDiscounts)) {
return;
}
......@@ -206,11 +206,11 @@ public static function onQuiqqerProductsCalcList(
) {
$userDiscounts = self::getUserDiscounts($Calc->getUser());
if (!is_array($userDiscounts)) {
if (!\is_array($userDiscounts)) {
return;
}
$userDiscounts = array_filter($userDiscounts, function ($Discount) {
$userDiscounts = \array_filter($userDiscounts, function ($Discount) {
/* @var $Discount Discount */
// don't use manuel usage type
......@@ -221,7 +221,7 @@ public static function onQuiqqerProductsCalcList(
return $Discount->getAttribute('scope') == Handler::DISCOUNT_SCOPE_TOTAL;
});
if (!is_array($userDiscounts)) {
if (!\is_array($userDiscounts)) {
return;
}
......@@ -242,7 +242,7 @@ public static function onQuiqqerProductsCalcList(
$productIds = $Discount->getAttribute('articles');
if ($productIds) {
$productIds = explode(',', $productIds);
$productIds = \explode(',', $productIds);
// product id check
$existProductIdInList = function ($products, $productIds) {
......@@ -267,7 +267,7 @@ public static function onQuiqqerProductsCalcList(
$categories = $Discount->getAttribute('categories');
if ($categories) {
$categories = explode(',', $categories);
$categories = \explode(',', $categories);
// product category check
$existCategoryInList = function ($products, $categories) {
......
......@@ -26,7 +26,7 @@ class Utils
public static function getUserDiscounts(UserInterface $User)
{
$guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.str_replace(',', ',|,', $guString).',';
$guString = ','.\str_replace(',', ',|,', $guString).',';
$result = [];
$Discounts = new Handler();
......@@ -48,11 +48,11 @@ public static function getUserDiscounts(UserInterface $User)
if (!empty($personalDiscounts)) {
$result = array_merge($personalDiscounts, $result);
$result = \array_merge($personalDiscounts, $result);
}
if (!empty($discounts)) {
$result = array_merge($discounts, $result);
$result = \array_merge($discounts, $result);
}
return $result;
......@@ -86,11 +86,11 @@ public static function getProductDiscounts(Product $Product)
if (!empty($productDiscounts)) {
$result = array_merge($productDiscounts, $result);
$result = \array_merge($productDiscounts, $result);
}
if (!empty($discounts)) {
$result = array_merge($discounts, $result);
$result = \array_merge($discounts, $result);
}
return $result;
......@@ -105,7 +105,7 @@ public static function getProductDiscounts(Product $Product)
public static function getActiveUserDiscounts(UserInterface $User)
{
$guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.str_replace(',', ',|,', $guString).',';
$guString = ','.\str_replace(',', ',|,', $guString).',';
$result = [];
$Discounts = new Handler();
......@@ -129,11 +129,11 @@ public static function getActiveUserDiscounts(UserInterface $User)
if (!empty($personalDiscounts)) {
$result = array_merge($personalDiscounts, $result);
$result = \array_merge($personalDiscounts, $result);
}
if (!empty($discounts)) {
$result = array_merge($discounts, $result);
$result = \array_merge($discounts, $result);
}
return $result;
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren