本文整理汇总了PHP中Piwik\Plugins\CustomVariables\CustomVariables::getMaxLengthCustomVariables方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomVariables::getMaxLengthCustomVariables方法的具体用法?PHP CustomVariables::getMaxLengthCustomVariables怎么用?PHP CustomVariables::getMaxLengthCustomVariables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Plugins\CustomVariables\CustomVariables
的用法示例。
在下文中一共展示了CustomVariables::getMaxLengthCustomVariables方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCustomVariable
public function addCustomVariable()
{
$dbTable = $this->getDbTableName();
$index = $this->getHighestCustomVarIndex() + 1;
$maxLen = CustomVariables::getMaxLengthCustomVariables();
Db::exec(sprintf('ALTER TABLE %s ', $dbTable) . sprintf('ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL,', $index, $maxLen) . sprintf('ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL;', $index, $maxLen));
return $index;
}
示例2: truncateCustomVariable
public static function truncateCustomVariable($input)
{
return substr(trim($input), 0, CustomVariables::getMaxLengthCustomVariables());
}
示例3: test_getCustomVariablesInPageScope_ShouldTruncateValuesIfTheyAreTooLong
public function test_getCustomVariablesInPageScope_ShouldTruncateValuesIfTheyAreTooLong()
{
$maxLen = CustomVariables::getMaxLengthCustomVariables();
$customVars = $this->buildCustomVars(array('mykey' => 'myval', 'test' => str_pad('test', $maxLen + 5, 't')));
$expected = $this->buildExpectedCustomVars(array('mykey' => 'myval', 'test' => str_pad('test', $maxLen, 't')));
$this->assertCustomVariablesInPageScope($expected, $customVars);
}
示例4: test_truncateCustomVariable_shouldActuallyTruncateTheValue
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);
}