/** * @inheritdoc * @return string */ public function filter($value) { if (is_null($value)) { $value = $this->default; } $value = StringHelper::toStr($value); return StringHelper::strCrop(StringHelper::strPad($value, $this->minLength, $this->padString, $this->padType), $this->maxLength, $this->cropType); }
/** * @inheritdoc * @return string */ public function filter($value) { if (!is_string($value)) { $value = StringHelper::toStr($value); } $pattern = StringHelper::toStr($this->pattern); $replacement = StringHelper::toStr($this->replacement); if (is_string($pattern) && !empty($pattern) && !empty($replacement)) { $value = preg_replace($pattern, $replacement, $value); } return parent::filter($value); }