original_string: public function append($url, $formatterName = null)
      {
          $urlComponents = parse_url($url);
  
          $parameters = array();
          if (isset($urlComponents['query'])) {
              parse_str($urlComponents['query'], $parameters);
          }
  
          $trackingParameters = $this->persister->getAllTrackingParameters();
  
          if (null !== $formatterName) {
              $foundFormatter = $this->findFormatterByName($formatterName);
  
              if (null === $foundFormatter) {
                  throw new InvalidConfigurationException(sprintf('Unknown formatter "%s".', $formatterName));
              }
  
              $parameters = array_merge(
                  $parameters,
                  $this->formatters[$foundFormatter]->format($trackingParameters)
              );
  
              $parameters = $this->formatters[$foundFormatter]->checkFormat($parameters);
          }
  
          /** Search for tracking parameters to replace in query's parameters. */
          foreach ($parameters as $parameterName => $parameterValue) {
              if (!is_array($parameterValue) && preg_match('`^{\s?(?<parameter>[a-z0-9_]+)\s?}$`i', $parameterValue, $matches)) {
                  $parameters[$parameterName] = $trackingParameters->get($matches['parameter'], null);
              }
          }
  
          /** Rebuild the query parameters string. */
          $urlComponents['query'] = http_build_query($parameters, null, '&', PHP_QUERY_RFC3986);
          if (true === empty($urlComponents['query'])) {
              /* Force to null to avoid single "?" at the end of url */
              $urlComponents['query'] = null;
          }
  
          return $this->buildUrl($urlComponents);
      }
code: public function append($url, $formatterName = null)
      {
          $urlComponents = parse_url($url);
  
          $parameters = array();
          if (isset($urlComponents['query'])) {
              parse_str($urlComponents['query'], $parameters);
          }
  
          $trackingParameters = $this->persister->getAllTrackingParameters();
  
          if (null !== $formatterName) {
              $foundFormatter = $this->findFormatterByName($formatterName);
  
              if (null === $foundFormatter) {
                  throw new InvalidConfigurationException(sprintf('Unknown formatter "%s".', $formatterName));
              }
  
              $parameters = array_merge(
                  $parameters,
                  $this->formatters[$foundFormatter]->format($trackingParameters)
              );
  
              $parameters = $this->formatters[$foundFormatter]->checkFormat($parameters);
          }
  
          /** Search for tracking parameters to replace in query's parameters. */
          foreach ($parameters as $parameterName => $parameterValue) {
              if (!is_array($parameterValue) && preg_match('`^{\s?(?<parameter>[a-z0-9_]+)\s?}$`i', $parameterValue, $matches)) {
                  $parameters[$parameterName] = $trackingParameters->get($matches['parameter'], null);
              }
          }
  
          /** Rebuild the query parameters string. */
          $urlComponents['query'] = http_build_query($parameters, null, '&', PHP_QUERY_RFC3986);
          if (true === empty($urlComponents['query'])) {
              /* Force to null to avoid single "?" at the end of url */
              $urlComponents['query'] = null;
          }
  
          return $this->buildUrl($urlComponents);
      }
code_tokens: public function append ( $ url , $ formatterName = null ) { $ urlComponents = parse_url ( $ url ) ; $ parameters = array ( ) ; if ( isset ( $ urlComponents [ 'query' ] ) ) { parse_str ( $ urlComponents [ 'query' ] , $ parameters ) ; } $ trackingParameters = $ this -> persister -> getAllTrackingParameters ( ) ; if ( null !== $ formatterName ) { $ foundFormatter = $ this -> findFormatterByName ( $ formatterName ) ; if ( null === $ foundFormatter ) { throw new InvalidConfigurationException ( sprintf ( 'Unknown formatter "%s".' , $ formatterName ) ) ; } $ parameters = array_merge ( $ parameters , $ this -> formatters [ $ foundFormatter ] -> format ( $ trackingParameters ) ) ; $ parameters = $ this -> formatters [ $ foundFormatter ] -> checkFormat ( $ parameters ) ; } /** Search for tracking parameters to replace in query's parameters. */ foreach ( $ parameters as $ parameterName => $ parameterValue ) { if ( ! is_array ( $ parameterValue ) && preg_match ( '`^{\s?(?<parameter>[a-z0-9_]+)\s?}$`i' , $ parameterValue , $ matches ) ) { $ parameters [ $ parameterName ] = $ trackingParameters -> get ( $ matches [ 'parameter' ] , null ) ; } } /** Rebuild the query parameters string. */ $ urlComponents [ 'query' ] = http_build_query ( $ parameters , null , '&' , PHP_QUERY_RFC3986 ) ; if ( true === empty ( $ urlComponents [ 'query' ] ) ) { /* Force to null to avoid single "?" at the end of url */ $ urlComponents [ 'query' ] = null ; } return $ this -> buildUrl ( $ urlComponents ) ; }
docstring: Appends the query parameters depending on domain's formatters defined in configuration.
  
  @param string $url
  @param string $formatterName
  
  @return string
docstring_tokens: Appends the query parameters depending on domain s formatters defined in configuration .