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