Refactor filter factory into multiple functions
[MAILPOET-3220]
This commit is contained in:
@ -78,30 +78,46 @@ class FilterFactory {
|
|||||||
$action = $filterData->getParam('action');
|
$action = $filterData->getParam('action');
|
||||||
switch ($filterType) {
|
switch ($filterType) {
|
||||||
case DynamicSegmentFilterData::TYPE_USER_ROLE:
|
case DynamicSegmentFilterData::TYPE_USER_ROLE:
|
||||||
if ($action === SubscriberSubscribedDate::TYPE) {
|
return $this->userRole($action);
|
||||||
return $this->subscriberSubscribedDate;
|
|
||||||
}
|
|
||||||
return $this->userRole;
|
|
||||||
case DynamicSegmentFilterData::TYPE_EMAIL:
|
case DynamicSegmentFilterData::TYPE_EMAIL:
|
||||||
if ($action === EmailOpensAbsoluteCountAction::TYPE) {
|
return $this->email($action);
|
||||||
return $this->emailOpensAbsoluteCount;
|
|
||||||
}
|
|
||||||
return $this->emailAction;
|
|
||||||
case DynamicSegmentFilterData::TYPE_WOOCOMMERCE_SUBSCRIPTION:
|
case DynamicSegmentFilterData::TYPE_WOOCOMMERCE_SUBSCRIPTION:
|
||||||
return $this->wooCommerceSubscription;
|
return $this->wooCommerceSubscription();
|
||||||
case DynamicSegmentFilterData::TYPE_WOOCOMMERCE:
|
case DynamicSegmentFilterData::TYPE_WOOCOMMERCE:
|
||||||
if ($action === WooCommerceProduct::ACTION_PRODUCT) {
|
return $this->wooCommerce($action);
|
||||||
return $this->wooCommerceProduct;
|
|
||||||
} elseif ($action === WooCommerceNumberOfOrders::ACTION_NUMBER_OF_ORDERS) {
|
|
||||||
return $this->wooCommerceNumberOfOrders;
|
|
||||||
} elseif ($action === WooCommerceTotalSpent::ACTION_TOTAL_SPENT) {
|
|
||||||
return $this->wooCommerceTotalSpent;
|
|
||||||
} elseif ($action === WooCommerceCountry::ACTION_CUSTOMER_COUNTRY) {
|
|
||||||
return $this->wooCommerceCountry;
|
|
||||||
}
|
|
||||||
return $this->wooCommerceCategory;
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidFilterException('Invalid type', InvalidFilterException::INVALID_TYPE);
|
throw new InvalidFilterException('Invalid type', InvalidFilterException::INVALID_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function userRole($action) {
|
||||||
|
if ($action === SubscriberSubscribedDate::TYPE) {
|
||||||
|
return $this->subscriberSubscribedDate;
|
||||||
|
}
|
||||||
|
return $this->userRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function email($action) {
|
||||||
|
if ($action === EmailOpensAbsoluteCountAction::TYPE) {
|
||||||
|
return $this->emailOpensAbsoluteCount;
|
||||||
|
}
|
||||||
|
return $this->emailAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function wooCommerceSubscription() {
|
||||||
|
return $this->wooCommerceSubscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function wooCommerce($action) {
|
||||||
|
if ($action === WooCommerceProduct::ACTION_PRODUCT) {
|
||||||
|
return $this->wooCommerceProduct;
|
||||||
|
} elseif ($action === WooCommerceNumberOfOrders::ACTION_NUMBER_OF_ORDERS) {
|
||||||
|
return $this->wooCommerceNumberOfOrders;
|
||||||
|
} elseif ($action === WooCommerceTotalSpent::ACTION_TOTAL_SPENT) {
|
||||||
|
return $this->wooCommerceTotalSpent;
|
||||||
|
} elseif ($action === WooCommerceCountry::ACTION_CUSTOMER_COUNTRY) {
|
||||||
|
return $this->wooCommerceCountry;
|
||||||
|
}
|
||||||
|
return $this->wooCommerceCategory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user