diff --git a/src/QUI/ERP/Discount/Discount.php b/src/QUI/ERP/Discount/Discount.php index 73cf0dc161fcb1aa9047a24f78359631ae756819..f7199d2eb3fb15394f19aae861bd8f7fb9074a62 100644 --- a/src/QUI/ERP/Discount/Discount.php +++ b/src/QUI/ERP/Discount/Discount.php @@ -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(); diff --git a/src/QUI/ERP/Discount/EventHandling.php b/src/QUI/ERP/Discount/EventHandling.php index fda602eadf375404bf9a28db00cee44b1f555e92..14fd306a09875ccff819dd6290f95dc5a9738a02 100644 --- a/src/QUI/ERP/Discount/EventHandling.php +++ b/src/QUI/ERP/Discount/EventHandling.php @@ -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) { diff --git a/src/QUI/ERP/Discount/Utils.php b/src/QUI/ERP/Discount/Utils.php index 311e3bc6fcfaafa85d62ddaf4f4069be83c753ff..28b3893a3fc7fa6dc17b19db852ec9bea71ac671 100644 --- a/src/QUI/ERP/Discount/Utils.php +++ b/src/QUI/ERP/Discount/Utils.php @@ -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;