truncateCustomVariable() public static method

public static truncateCustomVariable ( $input )
Example #1
0
 public function getCustomVariables()
 {
     $customVariables = parent::getCustomVariables();
     // Enrich Site Search actions with Custom Variables, overwriting existing values
     if (!empty($this->searchCategory)) {
         if (!empty($customVariables['custom_var_k' . self::CVAR_INDEX_SEARCH_CATEGORY])) {
             Common::printDebug("WARNING: Overwriting existing Custom Variable  in slot " . self::CVAR_INDEX_SEARCH_CATEGORY . " for this page view");
         }
         $customVariables['custom_var_k' . self::CVAR_INDEX_SEARCH_CATEGORY] = self::CVAR_KEY_SEARCH_CATEGORY;
         $customVariables['custom_var_v' . self::CVAR_INDEX_SEARCH_CATEGORY] = Request::truncateCustomVariable($this->searchCategory);
     }
     if ($this->searchCount !== false) {
         if (!empty($customVariables['custom_var_k' . self::CVAR_INDEX_SEARCH_COUNT])) {
             Common::printDebug("WARNING: Overwriting existing Custom Variable  in slot " . self::CVAR_INDEX_SEARCH_COUNT . " for this page view");
         }
         $customVariables['custom_var_k' . self::CVAR_INDEX_SEARCH_COUNT] = self::CVAR_KEY_SEARCH_COUNT;
         $customVariables['custom_var_v' . self::CVAR_INDEX_SEARCH_COUNT] = (int) $this->searchCount;
     }
     return $customVariables;
 }
Example #2
0
 public function test_truncateCustomVariable_shouldActuallyTruncateTheValue()
 {
     $len = CustomVariables::getMaxLengthCustomVariables();
     $input = str_pad('test', $len + 2, 't');
     $this->assertGreaterThan(100, $len);
     $truncated = Request::truncateCustomVariable($input);
     $this->assertEquals(str_pad('test', $len, 't'), $truncated);
 }