mirror of
https://github.com/Mibew/handlebars.php-helpers.git
synced 2025-03-22 13:41:27 +03:00
Use snake case in Ellipsis helper local variable names
This commit is contained in:
parent
44cee94f62
commit
f875ede983
@ -43,7 +43,7 @@ class EllipsisHelper implements HelperInterface
|
|||||||
'"ellipsis" helper expects two or three arguments.'
|
'"ellipsis" helper expects two or three arguments.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$varContent = (string)$context->get($parsed_args[0]);
|
$var_content = (string)$context->get($parsed_args[0]);
|
||||||
$limit = intval($context->get($parsed_args[1]));
|
$limit = intval($context->get($parsed_args[1]));
|
||||||
$ellipsis = isset($parsed_args[2]) ? (string)$context->get($parsed_args[2]) : '';
|
$ellipsis = isset($parsed_args[2]) ? (string)$context->get($parsed_args[2]) : '';
|
||||||
if ($limit === 0) {
|
if ($limit === 0) {
|
||||||
@ -54,22 +54,23 @@ class EllipsisHelper implements HelperInterface
|
|||||||
'The second argument of "ellipsis" helper has to be greater than or equal to 0.'
|
'The second argument of "ellipsis" helper has to be greater than or equal to 0.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$words = str_word_count($varContent, 2);
|
$words = str_word_count($var_content, 2);
|
||||||
$value = "";
|
$value = "";
|
||||||
if (count($words) > $limit) {
|
if (count($words) > $limit) {
|
||||||
$permitted = array_slice($words, 0, $limit, true);
|
$permitted = array_slice($words, 0, $limit, true);
|
||||||
end($permitted);
|
end($permitted);
|
||||||
$lastWordPosition = key($permitted);
|
$last_word_position = key($permitted);
|
||||||
$lastWord = $permitted[$lastWordPosition];
|
$last_word = $permitted[$last_word_position];
|
||||||
$lastWordLength = strlen($lastWord);
|
$last_word_length = strlen($last_word);
|
||||||
$realLimit = $lastWordPosition+$lastWordLength;
|
$real_limit = $last_word_position + $last_word_length;
|
||||||
$value = substr($varContent, 0, $realLimit);
|
$value = substr($var_content, 0, $real_limit);
|
||||||
} else {
|
} else {
|
||||||
$value .= $varContent;
|
$value .= $var_content;
|
||||||
}
|
}
|
||||||
if ($ellipsis) {
|
if ($ellipsis) {
|
||||||
$value .= $ellipsis;
|
$value .= $ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user