PropertyModifierSubstring: allow to skip length

This commit is contained in:
Thomas Gelf 2017-08-18 21:50:20 +02:00
parent ffb0177a16
commit 480573cba0

View file

@ -33,6 +33,18 @@ class PropertyModifierSubstring extends PropertyModifierHook
public function transform($value)
{
return substr($value, $this->getSetting('start'), $this->getSetting('length'));
$length = $this->getSetting('length');
if (is_numeric($length)) {
return substr(
$value,
(int) $this->getSetting('start'),
(int) $length
);
} else {
return substr(
$value,
(int) $this->getSetting('start')
);
}
}
}