truncates given value to max length

@param   string  $value
@return  string|Secret
@throws  \LogicException
@since   2.3.1
183702
public function truncateToMaxBorder($value)
    {
        if ($this->allowsTruncate($value)) {
            if ($value instanceof Secret) {
                return $value->substring(0, $this->maxLength);
            }

            return substr($value, 0, $this->maxLength);
        }

        throw new \LogicException('Truncate value to max length not allowed');
    }
1289606
public static function truncate($s, $maxlength = null, $continue = "\xe2\x80\xa6", &$is_cutted = null, $tail_min_length = 20)
	{
		return self::str_limit($s, $maxlength, $continue, $is_cutted, $tail_min_length);
	}
1198860
public function pluralize($value)
    {
        $key = $this->truncate ? self::APPEND : '_';

        return $this->getValue($value, $key, $this->plurals, $this->cache['p'], $this->truncate);
    }
966153
public static function limit($value, $limit = 100, $end = '...')
    {
        if (mb_strwidth($value, 'UTF-8') <= $limit) {
            return $value;
        }

        return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
    }
360419
final protected function valueInBounds($value)
    {
        return is_null($value) || (
            (is_null($this->getMinLength()) || strlen($value) >= $this->getMinLength())
            &&
            (is_null($this->getMaxLength()) || strlen($value) <= $this->getMaxLength())
        );
    }
1360363
public function setExtension($value)
    {
        if (!in_array($value, self::allowedTypes(), true)) {
            throw new DomainException(sprintf(self::MSG_UNEXPECTED_EXTENSION, implode(', ', self::allowedTypes())));
        }

        return $this->setAttribute('extension', $value);
    }
1188551
public function transform($value)
    {
        if (null === $value) {
            return '';
        }

        if (!$this->mask) {
            return $value;
        }

        return str_repeat($this->maskSymbol, $this->maskLength);
    }
51731
function truncate (value, length) {
  length = length || 15
  if( !value || typeof value !== 'string' ) return ''
  if( value.length <= length) return value
  return value.substring(0, length) + '...'
}
848731
public function validate($value)
    {
        if (empty($value)) {
            throw new RuntimeException('Expected a domain value');
        }

        if (strlen($value) > 253) {
            throw new RuntimeException("Specified domain '$value' is too long. Maximum length of 253 characters permitted");
        }

        if (!preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $value)) {
            throw new RuntimeException("Specified domain '$value' contains illegal characters.");
        }

        if (!preg_match('/^[^\.]{1,63}(\.[^\.]{1,63})*$/', $value)) {
            throw new RuntimeException("Specified domain '$value' contains a segment that is too long. Maximum segment length of 63 characters permitted.");
        }

        return $value;
    }
545997
protected function aboveMaxBorder($value): bool
    {
        if (null === $this->maxDate) {
            return false;
        }

        if (!($value instanceof Datespan)) {
            throw new LogicException('Given value must be of instance ' . Datespan::class);
        }

        return $value->endsAfter($this->maxDate->change()->timeTo('23:59:59'));
    }
855475
public function validateMaxLength($value)
  {
    if (!isset($this->attr["maxlength"])) return true;

		$maxlength = trim($this->attr["maxlength"]);
    $length = strlen($value);

    if ($length > $maxlength) {
      $this->errors[] =  "\"{$this->label}\" contains {$length} characters, but it is limited to {$maxlength} characters. Please shorten the length.";
			return false;
		}

		return true;
  }
1208061
protected function _validator_maxlength($input, $value, $max) {
		if (!is_string($value)) return false;
		if (strlen($value) > $max) return false;
		return true;
	}
83645
protected function wrap($value)
    {
        if ($value instanceof Expression) {
            return $this->handleExpressions($value->getExpressions());
        }

        $wrapped = [];

        foreach (explode('.', $value) as $segment) {
            if ($segment == '*') {
                $wrapped[] = $segment;
            } else {
                $wrapped[] = sprintf($this->wrapper, $segment);
            }
        }

        return implode('.', $wrapped);
    }
976892
public function endsWith(string $value): bool
    {
        if ($value === '') {
            return true;
        }

        return (string) $this->takeEnd(self::of($value, $this->encoding)->length()) === $value;
    }
481555
public static function maxLength($value, $length)
    {
        return Validator::string()->length(null, $length)->validate($value);
    }
217888
public function decryptValue($value)
    {
        $decoded = base64_decode($value);
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, $decoded, MCRYPT_MODE_ECB, $iv);

        return trim($text);
    }
376077
public function setCoreFriendlyAliasMaxLength($value)
    {
        $this->setFieldName('friendly_alias_max_length');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }