protected $helperSet = null;
/**
- * Sets the helper set associated with this helper.
- *
- * @param HelperSet $helperSet A HelperSet instance
+ * {@inheritdoc}
*/
public function setHelperSet(HelperSet $helperSet = null)
{
}
/**
- * Gets the helper set associated with this helper.
- *
- * @return HelperSet|null
+ * {@inheritdoc}
*/
public function getHelperSet()
{
public static function strlen($string)
{
if (false === $encoding = mb_detect_encoding($string, null, true)) {
- return strlen($string);
+ return \strlen($string);
}
return mb_strwidth($string, $encoding);
}
+ /**
+ * Returns the subset of a string, using mb_substr if it is available.
+ *
+ * @param string $string String to subset
+ * @param int $from Start offset
+ * @param int|null $length Length to read
+ *
+ * @return string The string subset
+ */
+ public static function substr($string, $from, $length = null)
+ {
+ if (false === $encoding = mb_detect_encoding($string, null, true)) {
+ return substr($string, $from, $length);
+ }
+
+ return mb_substr($string, $from, $length, $encoding);
+ }
+
public static function formatTime($secs)
{
static $timeFormats = array(
foreach ($timeFormats as $index => $format) {
if ($secs >= $format[0]) {
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
- || $index == count($timeFormats) - 1
+ || $index == \count($timeFormats) - 1
) {
- if (2 == count($format)) {
+ if (2 == \count($format)) {
return $format[1];
}