/**
  * normalize helper function.
  *
  * the utm_source is structured as: banner.landing_page.payment_method_family
  */
 protected function setUtmSource()
 {
     $utm_source = $this->getVal('utm_source');
     $utm_source_id = $this->getVal('utm_source_id');
     if ($this->getVal('payment_method')) {
         $method_object = PaymentMethod::newFromCompoundName($this->gateway, $this->getVal('payment_method'), $this->getVal('payment_submethod'), $this->getVal('recurring'));
         $utm_payment_method_family = $method_object->getUtmSourceName();
     } else {
         $utm_payment_method_family = '';
     }
     $recurring_str = var_export($this->getVal('recurring'), true);
     $this->logger->debug(__FUNCTION__ . ": Payment method is {$this->getVal('payment_method')}, recurring = {$recurring_str}, utm_source = {$utm_payment_method_family}");
     // split the utm_source into its parts for easier manipulation
     $source_parts = explode(".", $utm_source);
     // If we don't have the banner or any utm_source, set it to the empty string.
     if (empty($source_parts[0])) {
         $source_parts[0] = '';
     }
     // If the utm_source_id is set, include that in the landing page
     // portion of the string.
     if ($utm_source_id) {
         $source_parts[1] = $utm_payment_method_family . $utm_source_id;
     } else {
         if (empty($source_parts[1])) {
             $source_parts[1] = '';
         }
     }
     $source_parts[2] = $utm_payment_method_family;
     if (empty($source_parts[2])) {
         $source_parts[2] = '';
     }
     // reconstruct, and set the value.
     $utm_source = implode(".", $source_parts);
     $this->setVal('utm_source', $utm_source);
 }
 /**
  * @return PaymentMethod|null parent method or null if there is no parent
  */
 protected function getParent()
 {
     if (array_key_exists('group', $this->spec)) {
         return PaymentMethod::newFromCompoundName($this->gateway, $this->spec['group'], null, $this->is_recurring);
     }
     return null;
 }